Skip to content

Commit 2d6e267

Browse files
authored
Merge pull request #29 from FriedrichAltheide/proxy-settings
Use proxy when installing, if proxy is set
2 parents 9b68a96 + 7a3fcd6 commit 2d6e267

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

Diff for: modules/nixos/main.py

+33-3
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,25 @@
336336
337337
}
338338
"""
339-
339+
def env_is_set(name):
340+
envValue = os.environ.get(name)
341+
return not (envValue is None or envValue == "")
342+
343+
def generateProxyStrings():
344+
proxyEnv = []
345+
if env_is_set('http_proxy'):
346+
proxyEnv.append('http_proxy={}'.format(os.environ.get('http_proxy')))
347+
if env_is_set('https_proxy'):
348+
proxyEnv.append('https_proxy={}'.format(os.environ.get('https_proxy')))
349+
if env_is_set('HTTP_PROXY'):
350+
proxyEnv.append('HTTP_PROXY={}'.format(os.environ.get('HTTP_PROXY')))
351+
if env_is_set('HTTPS_PROXY'):
352+
proxyEnv.append('HTTPS_PROXY={}'.format(os.environ.get('HTTPS_PROXY')))
353+
354+
if len(proxyEnv) > 0:
355+
proxyEnv.insert(0, "env")
356+
357+
return proxyEnv
340358

341359
def pretty_name():
342360
return _("Installing NixOS.")
@@ -791,13 +809,25 @@ def run():
791809
status = _("Installing NixOS")
792810
libcalamares.job.setprogress(0.3)
793811

812+
# build nixos-install command
813+
nixosInstallCmd = [ "pkexec" ]
814+
nixosInstallCmd.extend(generateProxyStrings())
815+
nixosInstallCmd.extend(
816+
[
817+
"nixos-install",
818+
"--no-root-passwd",
819+
"--root",
820+
root_mount_point
821+
]
822+
)
823+
794824
# Install customizations
795825
try:
796826
output = ""
797827
proc = subprocess.Popen(
798-
["pkexec", "nixos-install", "--no-root-passwd", "--root", root_mount_point],
828+
nixosInstallCmd,
799829
stdout=subprocess.PIPE,
800-
stderr=subprocess.STDOUT,
830+
stderr=subprocess.STDOUT
801831
)
802832
while True:
803833
line = proc.stdout.readline().decode("utf-8")

0 commit comments

Comments
 (0)