refactor: remove devshell code from buildRustPackage

This commit is contained in:
Yusuf Bera Ertan 2023-08-01 15:00:41 +03:00 committed by DavHau
parent 39a895d579
commit 5b4775c457
3 changed files with 4 additions and 113 deletions

View File

@ -28,8 +28,8 @@ in {
};
rust-crane = {
# buildProfile = "dev";
# buildFlags = ["--verbose"];
# runTests = false;
buildProfile = "dev";
buildFlags = ["--verbose"];
runTests = false;
};
}

View File

@ -157,36 +157,6 @@
l.mapAttrs
(name: version: {"${version}" = buildPackage name version;})
dreamLockInterface.packages;
mkShellForDrvs = drvs:
import ./devshell.nix {
inherit drvs lib;
inherit (config.deps) mkShell;
name = "devshell";
};
pkgShells =
l.mapAttrs
(
name: version: let
pkg = allPackages.${name}.${version};
in
mkShellForDrvs [pkg]
)
dreamLockInterface.packages;
allPackagesList =
l.mapAttrsToList
(name: version: allPackages.${name}.${version})
dreamLockInterface.packages;
packages = allPackages;
devShells =
pkgShells
// {
default = mkShellForDrvs allPackagesList;
};
in {
imports = [
# dream2nix.modules.drv-parts.mkDerivation
@ -197,7 +167,7 @@ in {
inherit config extendModules;
inherit (config) name version;
inherit
(packages.${dreamLockInterface.defaultPackageName}.${dreamLockInterface.defaultPackageVersion})
(allPackages.${config.name}.${config.version})
drvPath
outPath
outputs

View File

@ -1,79 +0,0 @@
{
# args
drvs,
name,
# nixpkgs
lib,
mkShell,
}: let
l = lib // builtins;
# illegal env names to be removed and not be added to the devshell
illegalEnvNames =
[
"src"
"name"
"pname"
"version"
"args"
"stdenv"
"builder"
"outputs"
"phases"
# cargo artifact and vendoring derivations
# we don't need these in the devshell
"cargoArtifacts"
"dream2nixVendorDir"
"cargoVendorDir"
]
++ (
l.map
(phase: "${phase}Phase")
["configure" "build" "check" "install" "fixup" "unpack"]
)
++ l.flatten (
l.map
(phase: ["pre${phase}" "post${phase}"])
["Configure" "Build" "Check" "Install" "Fixup" "Unpack"]
);
isIllegalEnv = name: l.elem name illegalEnvNames;
getEnvs = drv:
# filter out attrsets, functions and illegal environment vars
l.filterAttrs
(name: env: (env != null) && (! isIllegalEnv name))
(
l.mapAttrs
(
n: v:
if ! (l.isAttrs v || l.isFunction v)
then v
else null
)
drv.drvAttrs
);
combineEnvs = envs:
l.foldl'
(
all: env: let
mergeInputs = name: (all.${name} or []) ++ (env.${name} or []);
in
all
// env
// {
buildInputs = mergeInputs "buildInputs";
nativeBuildInputs = mergeInputs "nativeBuildInputs";
propagatedBuildInputs = mergeInputs "propagatedBuildInputs";
propagatedNativeBuildInputs = mergeInputs "propagatedNativeBuildInputs";
}
)
{}
envs;
_shellEnv = combineEnvs (l.map getEnvs drvs);
shellEnv =
_shellEnv
// {
inherit name;
passthru.env = _shellEnv;
};
in
(mkShell.override {stdenv = (l.head drvs).stdenv;}) shellEnv