Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions nix_update/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Package:
go_modules: str | None
go_modules_old: str | None
cargo_deps: str | None
cargo_vendor_deps: str | None
npm_deps: str | None
pnpm_deps: str | None
yarn_deps: str | None
Expand Down Expand Up @@ -175,6 +176,7 @@ def eval_expression(
go_modules = pkg.goModules.outputHash or null;
go_modules_old = pkg.go-modules.outputHash or null;
cargo_deps = pkg.cargoDeps.outputHash or null;
cargo_vendor_deps = pkg.cargoDeps.vendorStaging.outputHash or null;
raw_cargo_lock =
if pkg ? cargoDeps.lockFile then
let
Expand Down
12 changes: 12 additions & 0 deletions nix_update/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ def update_cargo_deps_hash(opts: Options, filename: str, current_hash: str) -> N
replace_hash(filename, current_hash, target_hash)


def update_cargo_vendor_deps_hash(
opts: Options, filename: str, current_hash: str
) -> None:
target_hash = nix_prefetch(opts, "cargoDeps.vendorStaging")
replace_hash(filename, current_hash, target_hash)


def update_cargo_lock(
opts: Options, filename: str, dst: CargoLockInSource | CargoLockInStore
) -> None:
Expand Down Expand Up @@ -471,6 +478,11 @@ def update(opts: Options) -> Package:
if package.cargo_deps:
update_cargo_deps_hash(opts, package.filename, package.cargo_deps)

if package.cargo_vendor_deps:
update_cargo_vendor_deps_hash(
opts, package.filename, package.cargo_vendor_deps
)

if package.composer_deps:
update_composer_deps_hash(opts, package.filename, package.composer_deps)

Expand Down
81 changes: 81 additions & 0 deletions tests/test_cargo_vendor_deps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import subprocess

import conftest

from nix_update import main


def test_rust_package(helpers: conftest.Helpers) -> None:
with helpers.testpkgs(init_git=True) as path:
main(
[
"--file",
str(path),
"--commit",
"cargoVendorDeps.rustPackage",
"--version",
"0.7.3",
]
)
subprocess.run(
[
"nix",
"eval",
"--raw",
"--extra-experimental-features",
"nix-command",
"-f",
path,
"cargoVendorDeps.rustPackage.cargoDeps",
],
check=True,
text=True,
stdout=subprocess.PIPE,
).stdout.strip()

diff = subprocess.run(
["git", "-C", path, "show"],
text=True,
stdout=subprocess.PIPE,
check=True,
).stdout.strip()
print(diff)
assert "https://github.com/astral-sh/ruff/compare/0.7.0...0.7.3" in diff


def test_non_rust_package(helpers: conftest.Helpers) -> None:
with helpers.testpkgs(init_git=True) as path:
main(
[
"--file",
str(path),
"--commit",
"cargoVendorDeps.nonRustPackage",
"--version",
"v1.3.3",
]
)
subprocess.run(
[
"nix",
"eval",
"--raw",
"--extra-experimental-features",
"nix-command",
"-f",
path,
"cargoVendorDeps.nonRustPackage.cargoDeps",
],
check=True,
text=True,
stdout=subprocess.PIPE,
).stdout.strip()

diff = subprocess.run(
["git", "-C", path, "show"],
text=True,
stdout=subprocess.PIPE,
check=True,
).stdout.strip()
print(diff)
assert "https://github.com/pop-os/popsicle/compare/1.3.0...v1.3.3" in diff
26 changes: 26 additions & 0 deletions tests/testpkgs/cargo-vendor-deps/non-rust-package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
stdenv,
rustPlatform,
fetchFromGitHub,
}:
stdenv.mkDerivation rec {
pname = "popsicle";
version = "1.3.0";

src = fetchFromGitHub {
owner = "pop-os";
repo = "popsicle";
rev = version;
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};

nativeBuildInputs = [
rustPlatform.bindgenHook
rustPlatform.cargoSetupHook
];

cargoDeps = rustPlatform.fetchCargoVendor {
inherit pname version src;
hash = "sha256-BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB=";
};
}
18 changes: 18 additions & 0 deletions tests/testpkgs/cargo-vendor-deps/rust-package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
rustPlatform,
fetchFromGitHub,
}:
rustPlatform.buildRustPackage rec {
pname = "ruff";
version = "0.7.0";

src = fetchFromGitHub {
owner = "astral-sh";
repo = pname;
rev = version;
hash = "sha256-+8JKzKKWPQEanU2mh8p5sRjnoU6DawTQQi43qRXVXIg=";
};

useFetchCargoVendor = true;
cargoHash = "sha256-BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB=";
}
2 changes: 2 additions & 0 deletions tests/testpkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
{ };
cargoLock.update = pkgs.callPackage ./cargo-lock-update { };
composer = pkgs.callPackage ./composer.nix { };
cargoVendorDeps.nonRustPackage = pkgs.callPackage ./cargo-vendor-deps/non-rust-package.nix { };
cargoVendorDeps.rustPackage = pkgs.callPackage ./cargo-vendor-deps/rust-package.nix { };
composer-old = pkgs.callPackage ./composer-old.nix { };
crate = pkgs.callPackage ./crate.nix { };
gitea = pkgs.callPackage ./gitea.nix { };
Expand Down