Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
P-E-Meunier committed Dec 16, 2024
1 parent 9fed926 commit 260af59
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/tests-nix-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
matrix:
platform:
- macos-12
- macos-13
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
Expand Down
23 changes: 23 additions & 0 deletions sample_projects/bin_with_git_submodule_dep/Cargo.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

{ nixpkgs ? <nixpkgs>
, pkgs ? import nixpkgs { config = {}; }
, fetchurl ? pkgs.fetchurl
, lib ? pkgs.lib
, stdenv ? pkgs.stdenv
, buildRustCrateForPkgs ? pkgs: pkgs.buildRustCrate
Expand Down Expand Up @@ -61,6 +62,8 @@ rec {
};
};



# A derivation that joins the outputs of all workspace members together.
allWorkspaceMembers = pkgs.symlinkJoin {
name = "all-workspace-members";
Expand Down Expand Up @@ -1386,6 +1389,26 @@ rec {
debug_assertions = false;
};

registryUrl = { registries, url, crate, version, sha256 }:
let dl = registries.${url}.dl;
tmpl = [ "{crate}" "{version}" "{prefix}" "{lowerprefix}" "{sha256-checksum}" ];
in
with lib.strings;
if lib.lists.any (i: hasInfix "{}" dl) tmpl then
let prefix =
if builtins.stringLength crate == 1 then
"1"
else if builtins.stringLength crate == 2 then
"2"
else
"${builtins.substring 0 2 crate}/${builtins.substring 2 (builtins.stringLength crate - 2) crate}";
in
builtins.replaceStrings tmpl [
crate version prefix (lib.strings.toLower prefix) sha256
]
else
"${dl}/${crate}/${version}/download";

/* Filters common temp files and build files. */
# TODO(pkolloch): Substitute with gitignore filter
sourceFilter = name: type:
Expand Down
23 changes: 23 additions & 0 deletions sample_projects/codegen/Cargo.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

{ nixpkgs ? <nixpkgs>
, pkgs ? import nixpkgs { config = {}; }
, fetchurl ? pkgs.fetchurl
, lib ? pkgs.lib
, stdenv ? pkgs.stdenv
, buildRustCrateForPkgs ? pkgs: pkgs.buildRustCrate
Expand Down Expand Up @@ -61,6 +62,8 @@ rec {
};
};



# A derivation that joins the outputs of all workspace members together.
allWorkspaceMembers = pkgs.symlinkJoin {
name = "all-workspace-members";
Expand Down Expand Up @@ -561,6 +564,26 @@ rec {
debug_assertions = false;
};

registryUrl = { registries, url, crate, version, sha256 }:
let dl = registries.${url}.dl;
tmpl = [ "{crate}" "{version}" "{prefix}" "{lowerprefix}" "{sha256-checksum}" ];
in
with lib.strings;
if lib.lists.any (i: hasInfix "{}" dl) tmpl then
let prefix =
if builtins.stringLength crate == 1 then
"1"
else if builtins.stringLength crate == 2 then
"2"
else
"${builtins.substring 0 2 crate}/${builtins.substring 2 (builtins.stringLength crate - 2) crate}";
in
builtins.replaceStrings tmpl [
crate version prefix (lib.strings.toLower prefix) sha256
]
else
"${dl}/${crate}/${version}/download";

/* Filters common temp files and build files. */
# TODO(pkolloch): Substitute with gitignore filter
sourceFilter = name: type:
Expand Down
23 changes: 23 additions & 0 deletions sample_projects/sub_dir_crates/Cargo.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

{ nixpkgs ? <nixpkgs>
, pkgs ? import nixpkgs { config = {}; }
, fetchurl ? pkgs.fetchurl
, lib ? pkgs.lib
, stdenv ? pkgs.stdenv
, buildRustCrateForPkgs ? pkgs: pkgs.buildRustCrate
Expand Down Expand Up @@ -61,6 +62,8 @@ rec {
};
};



# A derivation that joins the outputs of all workspace members together.
allWorkspaceMembers = pkgs.symlinkJoin {
name = "all-workspace-members";
Expand Down Expand Up @@ -170,6 +173,26 @@ rec {
debug_assertions = false;
};

registryUrl = { registries, url, crate, version, sha256 }:
let dl = registries.${url}.dl;
tmpl = [ "{crate}" "{version}" "{prefix}" "{lowerprefix}" "{sha256-checksum}" ];
in
with lib.strings;
if lib.lists.any (i: hasInfix "{}" dl) tmpl then
let prefix =
if builtins.stringLength crate == 1 then
"1"
else if builtins.stringLength crate == 2 then
"2"
else
"${builtins.substring 0 2 crate}/${builtins.substring 2 (builtins.stringLength crate - 2) crate}";
in
builtins.replaceStrings tmpl [
crate version prefix (lib.strings.toLower prefix) sha256
]
else
"${dl}/${crate}/${version}/download";

/* Filters common temp files and build files. */
# TODO(pkolloch): Substitute with gitignore filter
sourceFilter = name: type:
Expand Down

0 comments on commit 260af59

Please sign in to comment.