Skip to content

Instantly share code, notes, and snippets.

@sorki
Created February 21, 2021 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sorki/005360d3931ab2200fb4dfc0d7dd15f5 to your computer and use it in GitHub Desktop.
Save sorki/005360d3931ab2200fb4dfc0d7dd15f5 to your computer and use it in GitHub Desktop.
scoped self-import
let
roundTwo = builtins.hasAttr "inScope" builtins;
pinnedPath = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/2b973d233906fb0483263bca71bb789cad61513e.tar.gz";
sha256 = "11h21zsas7xgdax6xs2lh3mz8spvdk8i63czysr4p69yir1h1cd7";
};
in
if roundTwo
then throw "yep - ${<nixpkgs>}"
else
let
overrides = {
inScope = true;
__nixPath = [
{ prefix = "nixpkgs"; path = pinnedPath; }
] ++ builtins.nixPath;
import = fn: scopedImport overrides fn;
scopedImport = attrs: fn: scopedImport (overrides // attrs) fn;
builtins = builtins // overrides;
};
in
builtins.scopedImport
overrides
./.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment