diff --git a/.github/workflows/tests-nix-macos.yml b/.github/workflows/tests-nix-macos.yml index d4309390..02b139b7 100644 --- a/.github/workflows/tests-nix-macos.yml +++ b/.github/workflows/tests-nix-macos.yml @@ -7,7 +7,7 @@ jobs: strategy: matrix: platform: - - macos-12 + - macos-13 runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v4 diff --git a/sample_projects/bin_with_git_submodule_dep/Cargo.nix b/sample_projects/bin_with_git_submodule_dep/Cargo.nix index e731beef..ecfd54dd 100644 --- a/sample_projects/bin_with_git_submodule_dep/Cargo.nix +++ b/sample_projects/bin_with_git_submodule_dep/Cargo.nix @@ -5,6 +5,7 @@ { nixpkgs ? , pkgs ? import nixpkgs { config = {}; } +, fetchurl ? pkgs.fetchurl , lib ? pkgs.lib , stdenv ? pkgs.stdenv , buildRustCrateForPkgs ? pkgs: pkgs.buildRustCrate @@ -61,6 +62,8 @@ rec { }; }; + + # A derivation that joins the outputs of all workspace members together. allWorkspaceMembers = pkgs.symlinkJoin { name = "all-workspace-members"; @@ -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: diff --git a/sample_projects/codegen/Cargo.nix b/sample_projects/codegen/Cargo.nix index 8ff30078..18031924 100644 --- a/sample_projects/codegen/Cargo.nix +++ b/sample_projects/codegen/Cargo.nix @@ -5,6 +5,7 @@ { nixpkgs ? , pkgs ? import nixpkgs { config = {}; } +, fetchurl ? pkgs.fetchurl , lib ? pkgs.lib , stdenv ? pkgs.stdenv , buildRustCrateForPkgs ? pkgs: pkgs.buildRustCrate @@ -61,6 +62,8 @@ rec { }; }; + + # A derivation that joins the outputs of all workspace members together. allWorkspaceMembers = pkgs.symlinkJoin { name = "all-workspace-members"; @@ -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: diff --git a/sample_projects/sub_dir_crates/Cargo.nix b/sample_projects/sub_dir_crates/Cargo.nix index 6f2bdd02..f0f20888 100644 --- a/sample_projects/sub_dir_crates/Cargo.nix +++ b/sample_projects/sub_dir_crates/Cargo.nix @@ -5,6 +5,7 @@ { nixpkgs ? , pkgs ? import nixpkgs { config = {}; } +, fetchurl ? pkgs.fetchurl , lib ? pkgs.lib , stdenv ? pkgs.stdenv , buildRustCrateForPkgs ? pkgs: pkgs.buildRustCrate @@ -61,6 +62,8 @@ rec { }; }; + + # A derivation that joins the outputs of all workspace members together. allWorkspaceMembers = pkgs.symlinkJoin { name = "all-workspace-members"; @@ -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: