From 5b4775c457f43be8c8d01134b6582c8fc7f01cdc Mon Sep 17 00:00:00 2001 From: Yusuf Bera Ertan Date: Tue, 1 Aug 2023 15:00:41 +0300 Subject: [PATCH] refactor: remove devshell code from buildRustPackage --- .../ripgrep/default.nix | 6 +- .../drv-parts/buildRustPackage/default.nix | 32 +------- .../drv-parts/buildRustPackage/devshell.nix | 79 ------------------- 3 files changed, 4 insertions(+), 113 deletions(-) delete mode 100644 modules/drv-parts/buildRustPackage/devshell.nix diff --git a/examples/dream2nix-packages-rust/ripgrep/default.nix b/examples/dream2nix-packages-rust/ripgrep/default.nix index cf1b6e11..3a4e8889 100644 --- a/examples/dream2nix-packages-rust/ripgrep/default.nix +++ b/examples/dream2nix-packages-rust/ripgrep/default.nix @@ -28,8 +28,8 @@ in { }; rust-crane = { - # buildProfile = "dev"; - # buildFlags = ["--verbose"]; - # runTests = false; + buildProfile = "dev"; + buildFlags = ["--verbose"]; + runTests = false; }; } diff --git a/modules/drv-parts/buildRustPackage/default.nix b/modules/drv-parts/buildRustPackage/default.nix index 6b531ed7..0be78449 100644 --- a/modules/drv-parts/buildRustPackage/default.nix +++ b/modules/drv-parts/buildRustPackage/default.nix @@ -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 diff --git a/modules/drv-parts/buildRustPackage/devshell.nix b/modules/drv-parts/buildRustPackage/devshell.nix deleted file mode 100644 index 91e6c41c..00000000 --- a/modules/drv-parts/buildRustPackage/devshell.nix +++ /dev/null @@ -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