Skip to content

Commit 7fc874a

Browse files
committed
treewide: format again
1 parent dccf1ed commit 7fc874a

File tree

10 files changed

+97
-26
lines changed

10 files changed

+97
-26
lines changed

src/clean.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ use uzers::os::unix::UserExt;
3838

3939
use crate::{
4040
commands::Command,
41-
Result, interface,
41+
interface,
42+
Result,
4243
};
4344

4445
// Nix impl:

src/commands.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ impl Command {
4343
}
4444
}
4545

46-
#[must_use] pub const fn elevate(mut self, elevate: bool) -> Self {
46+
#[must_use]
47+
pub const fn elevate(mut self, elevate: bool) -> Self {
4748
self.elevate = elevate;
4849
self
4950
}
5051

51-
#[must_use] pub const fn dry(mut self, dry: bool) -> Self {
52+
#[must_use]
53+
pub const fn dry(mut self, dry: bool) -> Self {
5254
self.dry = dry;
5355
self
5456
}
@@ -157,7 +159,8 @@ pub struct Build {
157159
}
158160

159161
impl Build {
160-
#[must_use] pub const fn new(installable: Installable) -> Self {
162+
#[must_use]
163+
pub const fn new(installable: Installable) -> Self {
161164
Self {
162165
message: None,
163166
installable,
@@ -176,7 +179,8 @@ impl Build {
176179
self
177180
}
178181

179-
#[must_use] pub const fn nom(mut self, yes: bool) -> Self {
182+
#[must_use]
183+
pub const fn nom(mut self, yes: bool) -> Self {
180184
self.nom = yes;
181185
self
182186
}

src/completion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use color_eyre::Result;
33
use tracing::instrument;
44

55
use crate::{
6-
interface::Main,
76
interface,
7+
interface::Main,
88
};
99

1010
impl interface::CompletionArgs {

src/darwin.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ const CURRENT_PROFILE: &str = "/run/current-system";
3131

3232
impl DarwinArgs {
3333
pub fn run(self) -> Result<()> {
34-
use DarwinRebuildVariant::{Build, Switch};
34+
use DarwinRebuildVariant::{
35+
Build,
36+
Switch,
37+
};
3538
match self.subcommand {
3639
DarwinSubcommand::Switch(args) => args.rebuild(Switch),
3740
DarwinSubcommand::Build(args) => {
@@ -52,7 +55,10 @@ enum DarwinRebuildVariant {
5255

5356
impl DarwinRebuildArgs {
5457
fn rebuild(self, variant: DarwinRebuildVariant) -> Result<()> {
55-
use DarwinRebuildVariant::{Build, Switch};
58+
use DarwinRebuildVariant::{
59+
Build,
60+
Switch,
61+
};
5662

5763
if nix::unistd::Uid::effective().is_root() {
5864
bail!("Don't run nh os as root. I will call sudo internally as needed");

src/generations.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ pub struct GenerationInfo {
4141
pub current: bool,
4242
}
4343

44-
#[must_use] pub fn from_dir(generation_dir: &Path) -> Option<u64> {
44+
#[must_use]
45+
pub fn from_dir(generation_dir: &Path) -> Option<u64> {
4546
generation_dir
4647
.file_name()
4748
.and_then(|os_str| os_str.to_str())
@@ -172,7 +173,10 @@ pub fn print_info(mut generations: Vec<GenerationInfo>) {
172173
// Parse all dates at once and cache them
173174
let mut parsed_dates = HashMap::with_capacity(generations.len());
174175
for gen in &generations {
175-
let date = DateTime::parse_from_rfc3339(&gen.date).map_or_else(|_| Local.timestamp_opt(0, 0).unwrap(), |dt| dt.with_timezone(&Local));
176+
let date = DateTime::parse_from_rfc3339(&gen.date).map_or_else(
177+
|_| Local.timestamp_opt(0, 0).unwrap(),
178+
|dt| dt.with_timezone(&Local),
179+
);
176180
parsed_dates.insert(gen.date.clone(), date.format("%Y-%m-%d %H:%M:%S").to_string());
177181
}
178182

src/home.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ use crate::{
3030

3131
impl interface::HomeArgs {
3232
pub fn run(self) -> Result<()> {
33-
use HomeRebuildVariant::{Build, Switch};
33+
use HomeRebuildVariant::{
34+
Build,
35+
Switch,
36+
};
3437
match self.subcommand {
3538
HomeSubcommand::Switch(args) => args.rebuild(Switch),
3639
HomeSubcommand::Build(args) => {

src/installable.rs

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ impl FromArgMatches for Installable {
7474
let reference = elems.next().unwrap().to_owned();
7575
return Ok(Self::Flake {
7676
reference,
77-
attribute: parse_attribute(elems.next().map(std::string::ToString::to_string).unwrap_or_default()),
77+
attribute: parse_attribute(
78+
elems
79+
.next()
80+
.map(std::string::ToString::to_string)
81+
.unwrap_or_default(),
82+
),
7883
});
7984
}
8085

@@ -87,23 +92,38 @@ impl FromArgMatches for Installable {
8792
let mut elems = f.splitn(2, '#');
8893
return Ok(Self::Flake {
8994
reference: elems.next().unwrap().to_owned(),
90-
attribute: parse_attribute(elems.next().map(std::string::ToString::to_string).unwrap_or_default()),
95+
attribute: parse_attribute(
96+
elems
97+
.next()
98+
.map(std::string::ToString::to_string)
99+
.unwrap_or_default(),
100+
),
91101
});
92102
}
93103
} else if subcommand == "home" {
94104
if let Ok(f) = env::var("NH_HOME_FLAKE") {
95105
let mut elems = f.splitn(2, '#');
96106
return Ok(Self::Flake {
97107
reference: elems.next().unwrap().to_owned(),
98-
attribute: parse_attribute(elems.next().map(std::string::ToString::to_string).unwrap_or_default()),
108+
attribute: parse_attribute(
109+
elems
110+
.next()
111+
.map(std::string::ToString::to_string)
112+
.unwrap_or_default(),
113+
),
99114
});
100115
}
101116
} else if subcommand == "darwin" {
102117
if let Ok(f) = env::var("NH_DARWIN_FLAKE") {
103118
let mut elems = f.splitn(2, '#');
104119
return Ok(Self::Flake {
105120
reference: elems.next().unwrap().to_owned(),
106-
attribute: parse_attribute(elems.next().map(std::string::ToString::to_string).unwrap_or_default()),
121+
attribute: parse_attribute(
122+
elems
123+
.next()
124+
.map(std::string::ToString::to_string)
125+
.unwrap_or_default(),
126+
),
107127
});
108128
}
109129
}
@@ -113,31 +133,51 @@ impl FromArgMatches for Installable {
113133
let mut elems = f.splitn(2, '#');
114134
return Ok(Self::Flake {
115135
reference: elems.next().unwrap().to_owned(),
116-
attribute: parse_attribute(elems.next().map(std::string::ToString::to_string).unwrap_or_default()),
136+
attribute: parse_attribute(
137+
elems
138+
.next()
139+
.map(std::string::ToString::to_string)
140+
.unwrap_or_default(),
141+
),
117142
});
118143
}
119144

120145
if let Ok(f) = env::var("NH_OS_FLAKE") {
121146
let mut elems = f.splitn(2, '#');
122147
return Ok(Self::Flake {
123148
reference: elems.next().unwrap().to_owned(),
124-
attribute: parse_attribute(elems.next().map(std::string::ToString::to_string).unwrap_or_default()),
149+
attribute: parse_attribute(
150+
elems
151+
.next()
152+
.map(std::string::ToString::to_string)
153+
.unwrap_or_default(),
154+
),
125155
});
126156
}
127157

128158
if let Ok(f) = env::var("NH_HOME_FLAKE") {
129159
let mut elems = f.splitn(2, '#');
130160
return Ok(Self::Flake {
131161
reference: elems.next().unwrap().to_owned(),
132-
attribute: parse_attribute(elems.next().map(std::string::ToString::to_string).unwrap_or_default()),
162+
attribute: parse_attribute(
163+
elems
164+
.next()
165+
.map(std::string::ToString::to_string)
166+
.unwrap_or_default(),
167+
),
133168
});
134169
}
135170

136171
if let Ok(f) = env::var("NH_DARWIN_FLAKE") {
137172
let mut elems = f.splitn(2, '#');
138173
return Ok(Self::Flake {
139174
reference: elems.next().unwrap().to_owned(),
140-
attribute: parse_attribute(elems.next().map(std::string::ToString::to_string).unwrap_or_default()),
175+
attribute: parse_attribute(
176+
elems
177+
.next()
178+
.map(std::string::ToString::to_string)
179+
.unwrap_or_default(),
180+
),
141181
});
142182
}
143183

@@ -291,7 +331,8 @@ fn test_parse_attribute() {
291331
}
292332

293333
impl Installable {
294-
#[must_use] pub fn to_args(&self) -> Vec<String> {
334+
#[must_use]
335+
pub fn to_args(&self) -> Vec<String> {
295336
let mut res = Vec::new();
296337
match self {
297338
Self::Flake { reference, attribute } => {
@@ -371,7 +412,8 @@ fn test_join_attribute() {
371412
}
372413

373414
impl Installable {
374-
#[must_use] pub const fn str_kind(&self) -> &str {
415+
#[must_use]
416+
pub const fn str_kind(&self) -> &str {
375417
match self {
376418
Self::Flake { .. } => "flake",
377419
Self::File { .. } => "file",

src/json.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ impl Display for Error {
2929
impl std::error::Error for Error {}
3030

3131
impl<'v> Value<'v> {
32-
#[must_use] pub const fn new(value: &'v serde_json::Value) -> Self {
32+
#[must_use]
33+
pub const fn new(value: &'v serde_json::Value) -> Self {
3334
Self {
3435
inner: value,
3536
get_stack: vec![],

src/nixos.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ const SPEC_LOCATION: &str = "/etc/specialisation";
4444

4545
impl interface::OsArgs {
4646
pub fn run(self) -> Result<()> {
47-
use OsRebuildVariant::{Boot, Build, Switch, Test};
47+
use OsRebuildVariant::{
48+
Boot,
49+
Build,
50+
Switch,
51+
Test,
52+
};
4853
match self.subcommand {
4954
OsSubcommand::Boot(args) => args.rebuild(Boot),
5055
OsSubcommand::Test(args) => args.rebuild(Test),
@@ -71,7 +76,12 @@ enum OsRebuildVariant {
7176

7277
impl OsRebuildArgs {
7378
fn rebuild(self, variant: OsRebuildVariant) -> Result<()> {
74-
use OsRebuildVariant::{Boot, Build, Switch, Test};
79+
use OsRebuildVariant::{
80+
Boot,
81+
Build,
82+
Switch,
83+
Test,
84+
};
7585

7686
let elevate = if self.bypass_root_check {
7787
warn!("Bypassing root check, now running nix as root");

src/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ pub fn get_hostname() -> Result<String> {
123123
///
124124
/// # Returns
125125
///
126-
/// * `Result<HashSet<String>>` - A `HashSet` of enabled experimental features or
127-
/// an error.
126+
/// * `Result<HashSet<String>>` - A `HashSet` of enabled experimental features
127+
/// or an error.
128128
pub fn get_nix_experimental_features() -> Result<HashSet<String>> {
129129
let output = Command::new("nix")
130130
.args(["config", "show", "experimental-features"])

0 commit comments

Comments
 (0)