6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 1 | use std::{collections::BTreeMap, fs, path::PathBuf}; |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 2 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 3 | use serde::Deserialize; |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 4 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 5 | use crate::{ |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 6 | paths, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 7 | units::{Amount, Bytes, Dur}, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 8 | }; |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 9 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 10 | #[derive(Debug, Deserialize)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 11 | #[serde(default, deny_unknown_fields)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 12 | pub struct Config { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 13 | pub budget: Budget, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 14 | pub heavy: Heavy, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 15 | pub sizes: BTreeMap<String, Preset>, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 16 | pub queue: Queue, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 17 | pub overrun: Overrun, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 18 | pub enforce: Enforce, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 19 | pub artifacts: Artifacts, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 20 | pub nix: Nix, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 21 | pub detect: Detect, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 22 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 23 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 24 | #[derive(Debug, Deserialize)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 25 | #[serde(default, deny_unknown_fields)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 26 | pub struct Budget { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 27 | pub ram: Amount<Bytes>, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 28 | pub ram_reserve: Bytes, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 29 | pub cores: Amount<u32>, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 30 | pub disk_reserve: Bytes, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 31 | /// every lease's disk estimate is charged to all of these as well as its |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 32 | /// cwd. pessimistic when they share a fs, which is the point |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 33 | pub disk_paths: Vec<PathBuf>, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 34 | /// memory psi `some avg10`. only gates heavies |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 35 | pub psi_max: Option<f64>, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 36 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 37 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 38 | #[derive(Debug, Deserialize)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 39 | #[serde(default, deny_unknown_fields)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 40 | pub struct Heavy { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 41 | pub ram: Bytes, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 42 | pub cores: Amount<u32>, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 43 | pub disk: Bytes, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 44 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 45 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 46 | #[derive(Clone, Copy, Debug, Deserialize)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 47 | #[serde(deny_unknown_fields)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 48 | pub struct Preset { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 49 | pub ram: Bytes, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 50 | pub disk: Bytes, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 51 | pub cores: Amount<u32>, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 52 | pub time: Dur, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 53 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 54 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 55 | #[derive(Debug, Deserialize)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 56 | #[serde(default, deny_unknown_fields)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 57 | pub struct Queue { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 58 | pub linger: Dur, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 59 | pub backfill_max_time: Dur, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 60 | pub max_wait: Option<Dur>, |
ecc1cf8df0f5 | atagen | 2026-09-27 13:36 UTC | 61 | pub elastic: bool, |
ecc1cf8df0f5 | atagen | 2026-09-27 13:36 UTC | 62 | pub intent_ttl: Dur, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 63 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 64 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 65 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 66 | #[serde(rename_all = "lowercase")] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 67 | pub enum RamOverrun { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 68 | Warn, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 69 | Throttle, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 70 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 71 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 72 | #[derive(Debug, Deserialize)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 73 | #[serde(default, deny_unknown_fields)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 74 | pub struct Overrun { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 75 | pub ram: RamOverrun, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 76 | /// multiple of the ram estimate |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 77 | pub ram_slack: f64, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 78 | /// multiple of the time estimate |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 79 | pub time_grace: f64, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 80 | pub remind_every: Dur, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 81 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 82 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 83 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 84 | #[serde(rename_all = "lowercase")] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 85 | pub enum Unwrapped { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 86 | Deny, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 87 | Wrap, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 88 | Allow, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 89 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 90 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 91 | #[derive(Debug, Deserialize)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 92 | #[serde(default, deny_unknown_fields)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 93 | pub struct Enforce { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 94 | pub unwrapped: Unwrapped, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 95 | pub default_size: String, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 96 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 97 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 98 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 99 | #[serde(rename_all = "lowercase")] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 100 | pub enum OverCap { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 101 | Warn, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 102 | Block, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 103 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 104 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 105 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 106 | #[serde(rename_all = "lowercase")] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 107 | pub enum StopPolicy { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 108 | Block, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 109 | Nudge, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 110 | Warn, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 111 | Off, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 112 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 113 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 114 | #[derive(Clone, Debug, Deserialize)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 115 | #[serde(deny_unknown_fields)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 116 | pub struct Rule { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 117 | /// trailing `*` for a prefix match, that's all the glob you get |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 118 | pub name: String, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 119 | /// sibling that must exist, so we don't go deleting someone's `build/` |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 120 | /// because it had a suggestive name |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 121 | pub marker: Option<String>, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 122 | pub clean: Option<Vec<String>>, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 123 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 124 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 125 | #[derive(Debug, Deserialize)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 126 | #[serde(default, deny_unknown_fields)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 127 | pub struct Artifacts { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 128 | pub project_cap: Bytes, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 129 | pub global_cap: Bytes, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 130 | pub idle_after: Dur, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 131 | pub size_ttl: Dur, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 132 | pub over_cap: OverCap, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 133 | pub stop: StopPolicy, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 134 | pub rules: Vec<Rule>, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 135 | pub extra_rules: Vec<Rule>, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 136 | pub nix_gc: bool, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 137 | pub nix_min_free: Bytes, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 138 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 139 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 140 | #[derive(Debug, Deserialize)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 141 | #[serde(default, deny_unknown_fields)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 142 | pub struct Nix { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 143 | pub inject: bool, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 144 | pub cores_per_job: u32, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 145 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 146 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 147 | #[derive(Debug, Deserialize)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 148 | #[serde(default, deny_unknown_fields)] |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 149 | pub struct Detect { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 150 | pub commands: Vec<String>, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 151 | pub extra: Vec<String>, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 152 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 153 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 154 | impl Default for Config { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 155 | fn default() -> Self { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 156 | let preset = |ram, disk, cores: &str, time| Preset { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 157 | ram, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 158 | disk, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 159 | cores: cores.parse().unwrap_or(Amount::Abs(1)), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 160 | time: Dur::secs(time), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 161 | }; |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 162 | let sizes = BTreeMap::from([ |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 163 | ( |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 164 | "s".into(), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 165 | preset(Bytes::mib(512), Bytes::mib(256), "1", 60), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 166 | ), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 167 | ("m".into(), preset(Bytes::gib(2), Bytes::gib(1), "4", 300)), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 168 | ("l".into(), preset(Bytes::gib(6), Bytes::gib(5), "50%", 900)), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 169 | ( |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 170 | "xl".into(), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 171 | preset(Bytes::gib(12), Bytes::gib(20), "100%", 2700), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 172 | ), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 173 | ]); |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 174 | Self { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 175 | budget: Budget::default(), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 176 | heavy: Heavy::default(), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 177 | sizes, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 178 | queue: Queue::default(), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 179 | overrun: Overrun::default(), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 180 | enforce: Enforce::default(), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 181 | artifacts: Artifacts::default(), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 182 | nix: Nix::default(), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 183 | detect: Detect::default(), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 184 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 185 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 186 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 187 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 188 | impl Default for Budget { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 189 | fn default() -> Self { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 190 | Self { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 191 | ram: Amount::Percent(75.0), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 192 | ram_reserve: Bytes::gib(4), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 193 | cores: Amount::Percent(100.0), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 194 | disk_reserve: Bytes::gib(20), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 195 | disk_paths: vec!["/nix/store".into()], |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 196 | psi_max: Some(40.0), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 197 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 198 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 199 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 200 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 201 | impl Default for Heavy { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 202 | fn default() -> Self { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 203 | Self { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 204 | ram: Bytes::gib(4), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 205 | cores: Amount::Percent(50.0), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 206 | disk: Bytes::gib(5), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 207 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 208 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 209 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 210 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 211 | impl Default for Queue { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 212 | fn default() -> Self { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 213 | Self { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 214 | linger: Dur::secs(5), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 215 | backfill_max_time: Dur::secs(120), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 216 | max_wait: None, |
ecc1cf8df0f5 | atagen | 2026-09-27 13:36 UTC | 217 | elastic: true, |
ecc1cf8df0f5 | atagen | 2026-09-27 13:36 UTC | 218 | intent_ttl: Dur::secs(1200), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 219 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 220 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 221 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 222 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 223 | impl Default for Overrun { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 224 | fn default() -> Self { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 225 | Self { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 226 | ram: RamOverrun::Warn, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 227 | ram_slack: 1.25, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 228 | time_grace: 1.5, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 229 | remind_every: Dur::secs(300), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 230 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 231 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 232 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 233 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 234 | impl Default for Enforce { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 235 | fn default() -> Self { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 236 | Self { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 237 | unwrapped: Unwrapped::Deny, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 238 | default_size: "m".into(), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 239 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 240 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 241 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 242 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 243 | impl Default for Artifacts { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 244 | fn default() -> Self { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 245 | let rule = |name: &str, marker: Option<&str>| Rule { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 246 | name: name.into(), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 247 | marker: marker.map(Into::into), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 248 | clean: None, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 249 | }; |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 250 | Self { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 251 | project_cap: Bytes::gib(10), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 252 | global_cap: Bytes::gib(60), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 253 | idle_after: Dur::secs(86_400), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 254 | size_ttl: Dur::secs(600), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 255 | over_cap: OverCap::Warn, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 256 | stop: StopPolicy::Nudge, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 257 | rules: vec![ |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 258 | rule("target", Some("Cargo.toml")), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 259 | rule("result*", None), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 260 | rule("node_modules", Some("package.json")), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 261 | rule("zig-out", Some("build.zig")), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 262 | rule(".zig-cache", Some("build.zig")), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 263 | rule("_build", Some("dune-project")), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 264 | rule("dist-newstyle", Some("cabal.project")), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 265 | ], |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 266 | extra_rules: Vec::new(), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 267 | nix_gc: false, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 268 | nix_min_free: Bytes::gib(30), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 269 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 270 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 271 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 272 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 273 | impl Default for Nix { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 274 | fn default() -> Self { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 275 | Self { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 276 | inject: true, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 277 | cores_per_job: 4, |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 278 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 279 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 280 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 281 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 282 | impl Default for Detect { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 283 | fn default() -> Self { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 284 | let commands = [ |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 285 | "cargo build", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 286 | "cargo b", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 287 | "cargo test", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 288 | "cargo t", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 289 | "cargo check", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 290 | "cargo c", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 291 | "cargo clippy", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 292 | "cargo run", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 293 | "cargo r", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 294 | "cargo nextest", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 295 | "cargo bench", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 296 | "cargo install", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 297 | "cargo doc", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 298 | "nix build", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 299 | "nix flake check", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 300 | "nix develop", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 301 | "nix run", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 302 | "nix shell", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 303 | "nix-build", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 304 | "nix-shell", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 305 | "nixos-rebuild", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 306 | "home-manager switch", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 307 | "home-manager build", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 308 | "make", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 309 | "gmake", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 310 | "cmake --build", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 311 | "ninja", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 312 | "meson compile", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 313 | "go build", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 314 | "go test", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 315 | "zig build", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 316 | "dune build", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 317 | "cabal build", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 318 | "stack build", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 319 | "npm run build", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 320 | "npm test", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 321 | "npm ci", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 322 | "npm install", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 323 | "pnpm build", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 324 | "pnpm install", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 325 | "yarn build", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 326 | "bun run build", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 327 | "docker build", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 328 | "podman build", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 329 | "mvn", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 330 | "gradle", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 331 | "./gradlew", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 332 | "bazel build", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 333 | "bazel test", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 334 | ]; |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 335 | Self { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 336 | commands: commands.into_iter().map(Into::into).collect(), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 337 | extra: Vec::new(), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 338 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 339 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 340 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 341 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 342 | impl Config { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 343 | pub fn load() -> Result<Self, String> { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 344 | let path = paths::config_file(); |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 345 | match fs::read_to_string(&path) { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 346 | Ok(text) => Self::parse(&text).map_err(|e| format!("{}: {e}", path.display())), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 347 | Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(Self::default()), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 348 | Err(e) => Err(format!("{}: {e}", path.display())), |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 349 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 350 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 351 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 352 | pub fn parse(text: &str) -> Result<Self, toml::de::Error> { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 353 | let mut config: Self = toml::from_str(text)?; |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 354 | for (name, preset) in Self::default().sizes { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 355 | config.sizes.entry(name).or_insert(preset); |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 356 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 357 | Ok(config) |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 358 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 359 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 360 | pub fn preset(&self, name: &str) -> Result<Preset, String> { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 361 | self.sizes.get(name).copied().ok_or_else(|| { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 362 | let known: Vec<_> = self.sizes.keys().map(String::as_str).collect(); |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 363 | format!( |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 364 | "unknown size '{name}', known sizes are {}", |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 365 | known.join(", ") |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 366 | ) |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 367 | }) |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 368 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 369 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 370 | pub fn artifact_rules(&self) -> impl Iterator<Item = &Rule> { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 371 | self.artifacts |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 372 | .rules |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 373 | .iter() |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 374 | .chain(&self.artifacts.extra_rules) |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 375 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 376 | |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 377 | pub fn detect_patterns(&self) -> impl Iterator<Item = &str> { |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 378 | self.detect |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 379 | .commands |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 380 | .iter() |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 381 | .chain(&self.detect.extra) |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 382 | .map(String::as_str) |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 383 | } |
6f5b84fad3ef | atagen | 2026-09-27 03:59 UTC | 384 | } |