1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-29 09:02:46 +00:00

vimPlugins: run update script in empty environment

This commit is contained in:
Jörg Thalheim 2018-09-12 07:51:48 +01:00
parent ac415ca68e
commit c4a621d4a6

View file

@ -20,8 +20,9 @@ import xml.etree.ElementTree as ET
from datetime import datetime
from multiprocessing.dummy import Pool
from pathlib import Path
from typing import Dict, List, Optional, Tuple, Union
from typing import Dict, List, Optional, Tuple, Union, Any
from urllib.parse import urljoin, urlparse
from tempfile import NamedTemporaryFile
ATOM_ENTRY = "{http://www.w3.org/2005/Atom}entry"
ATOM_LINK = "{http://www.w3.org/2005/Atom}link"
@ -110,7 +111,7 @@ class Plugin:
return copy
GET_PLUGINS = """(with import <nixpkgs> {};
GET_PLUGINS = """(with import <localpkgs> {};
let
hasChecksum = value: lib.isAttrs value && lib.hasAttrByPath ["src" "outputHash"] value;
getChecksum = name: value:
@ -123,7 +124,23 @@ let
in lib.filterAttrs (n: v: v != null) checksums)"""
class CleanEnvironment(object):
def __enter__(self) -> None:
self.old_environ = os.environ.copy()
local_pkgs = str(ROOT.joinpath("../../.."))
os.environ["NIX_PATH"] = f"localpkgs={local_pkgs}"
self.empty_config = NamedTemporaryFile()
self.empty_config.write(b"{}")
self.empty_config.flush()
os.environ["NIXPKGS_CONFIG"] = self.empty_config.name
def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None:
os.environ.update(self.old_environ)
self.empty_config.close()
def get_current_plugins() -> List[Plugin]:
with CleanEnvironment():
out = subprocess.check_output(["nix", "eval", "--json", GET_PLUGINS])
data = json.loads(out)
plugins = []