Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(shell): revert from naked shell to pkgs.mkShell + unsetting irrelevant env vars #507

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 0 additions & 140 deletions src/modules/mkNakedShell.nix

This file was deleted.

54 changes: 45 additions & 9 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 @@ -144,22 +179,23 @@ 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;
shellHook = config.enterShell;
debug = config.devenv.debug;
}
);
packages = [ profile ];
shellHook = (lib.concatLines [
(lib.optionalString config.devenv.debug "set -x")
config.enterShell
]);
}));

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");
};
}