Skip to content

Commit 364dfc5

Browse files
committed
maybe_override_nixpkgs_config -> override_nixpkgs_config
1 parent 9caf563 commit 364dfc5

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

nix-script-directives/src/lib.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,14 @@ impl Directives {
163163
}
164164
}
165165

166-
pub fn maybe_override_nixpkgs_config(&mut self, new: Option<&Expr>) -> Result<()> {
167-
if let Some(expr) = new {
168-
match expr.kind() {
169-
SyntaxKind::NODE_ATTR_SET => self.nixpkgs_config = Some(expr.clone()),
170-
other => anyhow::bail!(
171-
"I expected the nixpkgs config to be a Nix record, but it was a `{:?}`",
172-
other,
173-
),
174-
};
175-
}
166+
pub fn override_nixpkgs_config(&mut self, expr: &Expr) -> Result<()> {
167+
match expr.kind() {
168+
SyntaxKind::NODE_ATTR_SET => self.nixpkgs_config = Some(expr.clone()),
169+
other => anyhow::bail!(
170+
"Nixpkgs config was no Nix attribute set, but a `{:?}`",
171+
other,
172+
),
173+
};
176174

177175
Ok(())
178176
}

nix-script/src/main.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,11 @@ impl Opts {
184184
.merge_runtime_inputs(&self.runtime_inputs)
185185
.context("could not add runtime inputs provided on the command line")?;
186186
directives.merge_runtime_files(&self.runtime_files);
187-
directives
188-
.maybe_override_nixpkgs_config(self.nixpkgs_config.as_ref())
189-
.context("could not set nixpkgs config provided on the command line")?;
187+
if let Some(expr) = self.nixpkgs_config.as_ref() {
188+
directives
189+
.override_nixpkgs_config(expr)
190+
.context("could not set nixpkgs config provided on the command line")?;
191+
}
190192

191193
// Second place we might bail early: if we're requesting a shell instead
192194
// of building and running the script.

0 commit comments

Comments
 (0)