Created
February 21, 2021 19:49
-
-
Save sorki/005360d3931ab2200fb4dfc0d7dd15f5 to your computer and use it in GitHub Desktop.
scoped self-import
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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