remove usage of IFD in nix packages

Lix builders have IFD disabled, and the changes needed to support this
are minimal.

We do need to do slightly more manual work to keep rust-toolchain.toml
in sync with flake.nix, but it's not significant.
This commit is contained in:
Benjamin Lee 2024-08-12 21:22:05 -07:00
parent b45c0afe37
commit 992e6b945a
No known key found for this signature in database
GPG key ID: FB9624E2885D55A4
3 changed files with 45 additions and 17 deletions

15
flake.lock generated
View file

@ -226,7 +226,8 @@
"flake-compat": "flake-compat_2",
"flake-utils": "flake-utils_2",
"nix-filter": "nix-filter",
"nixpkgs": "nixpkgs_2"
"nixpkgs": "nixpkgs_2",
"rust-manifest": "rust-manifest"
}
},
"rust-analyzer-src": {
@ -246,6 +247,18 @@
"type": "github"
}
},
"rust-manifest": {
"flake": false,
"locked": {
"narHash": "sha256-aZFye4UrtlcvLHrISldx4g9uGt3thDbVlLMK5keBSj0=",
"type": "file",
"url": "https://static.rust-lang.org/dist/channel-rust-1.78.0.toml"
},
"original": {
"type": "file",
"url": "https://static.rust-lang.org/dist/channel-rust-1.78.0.toml"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,

View file

@ -8,6 +8,12 @@
flake-utils.url = "github:numtide/flake-utils?ref=main";
nix-filter.url = "github:numtide/nix-filter?ref=main";
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
rust-manifest = {
# Keep version in sync with rust-toolchain.toml
url = "https://static.rust-lang.org/dist/channel-rust-1.78.0.toml";
flake = false;
};
};
outputs = inputs:
@ -29,16 +35,27 @@
shell = self.callPackage ./nix/shell.nix {};
# The Rust toolchain to use
toolchain = inputs
.fenix
.packages
.${pkgs.pkgsBuildHost.system}
.fromToolchainFile {
file = ./rust-toolchain.toml;
# See also `rust-toolchain.toml`
sha256 = "sha256-opUgs6ckUQCyDxcB9Wy51pqhd0MPGHUVbwRKKPGiwZU=";
};
# Using fromManifestFile and parsing the toolchain file with importTOML
# instead of fromToolchainFile to avoid IFD
toolchain = let
toolchainFile = pkgs.lib.importTOML ./rust-toolchain.toml;
defaultProfileComponents = [
"rustc"
"cargo"
"rust-docs"
"rustfmt"
"clippy"
];
components = defaultProfileComponents ++
toolchainFile.toolchain.components;
targets = toolchainFile.toolchain.targets;
fenix = inputs.fenix.packages.${pkgs.pkgsBuildHost.system};
in
fenix.combine (builtins.map
(target:
(fenix.targets.${target}.fromManifestFile inputs.rust-manifest)
.withComponents components)
targets);
});
in
inputs.flake-utils.lib.eachDefaultSystem (system:

View file

@ -71,12 +71,10 @@ let
} // buildDepsOnlyEnv;
commonAttrs = {
inherit
(craneLib.crateNameFromCargoToml {
cargoToml = "${inputs.self}/Cargo.toml";
})
pname
version;
# Reading from cargoManifest directly instead of using
# createNameFromCargoToml to avoid IFD
pname = cargoManifest.package.name;
version = cargoManifest.package.version;
src = let filter = inputs.nix-filter.lib; in filter {
root = inputs.self;