Skip to content

Commit

Permalink
Revert to pkgs.mkShell + unsetting irrelevant env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
thenonameguy committed Mar 24, 2023
1 parent a024182 commit 7bdefce
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 143 deletions.
137 changes: 0 additions & 137 deletions src/modules/mkNakedShell.nix

This file was deleted.

47 changes: 41 additions & 6 deletions src/modules/top-level.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{ config, pkgs, lib, ... }:
let
types = lib.types;
mkNakedShell = pkgs.callPackage ./mkNakedShell.nix { };
# Returns a list of all the entries in a folder
listEntries = path:
map (name: path + "/${name}") (builtins.attrNames (builtins.readDir path));
Expand Down Expand Up @@ -61,6 +60,42 @@ in
default = [ ];
};

unsetEnvVars = lib.mkOption {
type = types.listOf types.str;
description = "Remove these list of env vars from being exported to keep the shell/direnv more lean.";
# manually determined with knowledge from https://nixos.wiki/wiki/C
default = [
"HOST_PATH"
"NIX_BUILD_CORES"
"__structuredAttrs"
"buildInputs"
"buildPhase"
"builder"
"depsBuildBuild"
"depsBuildBuildPropagated"
"depsBuildTarget"
"depsBuildTargetPropagated"
"depsHostHost"
"depsHostHostPropagated"
"depsTargetTarget"
"depsTargetTargetPropagated"
"doCheck"
"doInstallCheck"
"nativeBuildInputs"
"out"
"outputs"
"patches"
"phases"
"preferLocalBuild"
"propagatedBuildInputs"
"propagatedNativeBuildInputs"
"shell"
"shellHook"
"stdenv"
"strictDeps"
];
};

shell = lib.mkOption {
type = types.package;
internal = true;
Expand Down Expand Up @@ -132,21 +167,21 @@ in
mkdir -p .devenv
rm -f .devenv/profile
ln -s ${profile} .devenv/profile
unset ${lib.concatStringsSep " " config.unsetEnvVars}
'';

shell = performAssertions (
mkNakedShell {
pkgs.mkShell ({
name = "devenv-shell";
env = config.env;
profile = profile;
packages = [ profile ];
shellHook = config.enterShell;
}
} // config.env)
);

infoSections."env" = lib.mapAttrsToList (name: value: "${name}: ${toString value}") config.env;
infoSections."packages" = builtins.map (package: package.name) (builtins.filter (package: !(builtins.elem package.name (builtins.attrNames config.scripts))) config.packages);

ci = [ config.shell.inputDerivation ];
ci = [ config.shell ];
ciDerivation = pkgs.runCommand "ci" { } ("ls " + toString config.ci + " && touch $out");
};
}

0 comments on commit 7bdefce

Please sign in to comment.