Skip to content

Commit daf7155

Browse files
committed
2024 edition update and other minor refactors
- Using edition 2024 for all crates - Fixed all checks/clippy warnings - [`clippy::wildcard_imports`](https://rust-lang.github.io/rust-clippy/stable/index.html#wildcard_imports) now warns for libnpins - `anyhow::Result` is now always fully qualified in libnpins - [Formatting code with the new edition](https://doc.rust-lang.org/edition-guide/rust-2024/rustfmt-formatting-fixes.html) - `cargo update` and turn off default features for `nix-compat`
1 parent 6dc715e commit daf7155

File tree

14 files changed

+142
-194
lines changed

14 files changed

+142
-194
lines changed

Cargo.lock

Lines changed: 18 additions & 88 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ tokio = "^1.0"
1111

1212
[workspace.package]
1313
version = "0.4.0"
14-
edition = "2021"
14+
edition = "2024"
1515
license = "EUPL-1.2"
1616

1717
[package]

libnpins/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ version.workspace = true
44
edition.workspace = true
55
license.workspace = true
66

7+
[lints.clippy]
8+
wildcard_imports = "warn"
9+
710
[dependencies]
811
serde = { version = "^1.0", features = [ "derive" ] }
912
serde_json.workspace = true
@@ -15,7 +18,7 @@ reqwest = { version = "0.13.1", features = [ "rustls" ], default-features = fals
1518
async-trait = "0.1"
1619
lenient_semver_parser = { version = "0.4.2", default-features = false }
1720
lenient_version = { version = "0.4.2" }
18-
nix-compat = { git = "https://git.snix.dev/snix/snix", version = "0.1.0", features = ["serde"] }
21+
nix-compat = { git = "https://git.snix.dev/snix/snix", version = "0.1.0", features = ["serde"], default-features = false }
1922

2023
[dev-dependencies]
2124
env_logger = { version = "^0.11.0", features = ["color", "auto-color", "regex"], default-features = false }

libnpins/src/channel.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
//!
33
//! This should be preferred over pinning the equivaleng `nixpkgs` git branch.
44
5-
use crate::*;
65
use nix_compat::nixhash::NixHash;
6+
use serde::{Deserialize, Serialize};
7+
8+
use crate::{Updatable, build_client, diff, nix};
79

810
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)]
911
pub struct Pin {
@@ -49,7 +51,7 @@ impl Updatable for Pin {
4951
type Version = ChannelVersion;
5052
type Hashes = ChannelHash;
5153

52-
async fn update(&self, _old: Option<&ChannelVersion>) -> Result<ChannelVersion> {
54+
async fn update(&self, _old: Option<&ChannelVersion>) -> anyhow::Result<ChannelVersion> {
5355
/* We want to get from something like https://channels.nixos.org/nixos-21.11
5456
* to https://releases.nixos.org/nixos/21.11/nixos-21.11.335807.df4f1f7cc3f/nixexprs.tar.xz
5557
*/
@@ -66,7 +68,7 @@ impl Updatable for Pin {
6668
Ok(ChannelVersion { url })
6769
}
6870

69-
async fn fetch(&self, version: &ChannelVersion) -> Result<Self::Hashes> {
71+
async fn fetch(&self, version: &ChannelVersion) -> anyhow::Result<Self::Hashes> {
7072
/* Prefetch an URL that looks like
7173
* https://releases.nixos.org/nixos/21.11/nixos-21.11.335807.df4f1f7cc3f
7274
*/

libnpins/src/container.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
//! Pin an OCI container
22
3-
use crate::nix::nix_prefetch_docker;
4-
use crate::*;
5-
use anyhow::Result;
63
use serde::{Deserialize, Serialize};
74

5+
use crate::{Updatable, diff, nix::nix_prefetch_docker};
6+
87
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)]
98
pub struct Pin {
109
pub image_name: String,
@@ -47,15 +46,15 @@ impl Updatable for Pin {
4746
type Version = ContainerVersion;
4847
type Hashes = ContainerHash;
4948

50-
async fn update(&self, _old: Option<&ContainerVersion>) -> Result<ContainerVersion> {
49+
async fn update(&self, _old: Option<&ContainerVersion>) -> anyhow::Result<ContainerVersion> {
5150
Ok(ContainerVersion {
5251
image_digest: nix_prefetch_docker(&self.image_name, &self.image_tag, None)
5352
.await?
5453
.image_digest,
5554
})
5655
}
5756

58-
async fn fetch(&self, version: &ContainerVersion) -> Result<ContainerHash> {
57+
async fn fetch(&self, version: &ContainerVersion) -> anyhow::Result<ContainerHash> {
5958
Ok(ContainerHash {
6059
hash: nix_prefetch_docker(
6160
&self.image_name,
@@ -72,7 +71,7 @@ impl Updatable for Pin {
7271
mod test {
7372
use super::*;
7473

75-
const DEAD_TEST_CONTAINER: &'static str = "docker.io/dperson/torproxy";
74+
const DEAD_TEST_CONTAINER: &str = "docker.io/dperson/torproxy";
7675

7776
#[tokio::test]
7877
async fn update_and_fetch_container() {

libnpins/src/flake.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
//! Convert+Import Nix flake lock files
22
3-
use crate::*;
43
use anyhow::{Context, Result};
54
use git::fetch_default_branch;
65
use serde::{Deserialize, Serialize};
76
use url::Url;
87

8+
use crate::{Pin, git, tarball};
9+
910
/// Pin entry from a nix flake's lock file
1011
///
1112
/// Flake locks have a two-part structure: the input's specification, and the

0 commit comments

Comments
 (0)