Skip to content

Commit

Permalink
Merge pull request #29 from FriedrichAltheide/proxy-settings
Browse files Browse the repository at this point in the history
Use proxy when installing, if proxy is set
  • Loading branch information
vlinkz authored Aug 28, 2024
2 parents 9b68a96 + 7a3fcd6 commit 2d6e267
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions modules/nixos/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,25 @@
}
"""

def env_is_set(name):
envValue = os.environ.get(name)
return not (envValue is None or envValue == "")

def generateProxyStrings():
proxyEnv = []
if env_is_set('http_proxy'):
proxyEnv.append('http_proxy={}'.format(os.environ.get('http_proxy')))
if env_is_set('https_proxy'):
proxyEnv.append('https_proxy={}'.format(os.environ.get('https_proxy')))
if env_is_set('HTTP_PROXY'):
proxyEnv.append('HTTP_PROXY={}'.format(os.environ.get('HTTP_PROXY')))
if env_is_set('HTTPS_PROXY'):
proxyEnv.append('HTTPS_PROXY={}'.format(os.environ.get('HTTPS_PROXY')))

if len(proxyEnv) > 0:
proxyEnv.insert(0, "env")

return proxyEnv

def pretty_name():
return _("Installing NixOS.")
Expand Down Expand Up @@ -791,13 +809,25 @@ def run():
status = _("Installing NixOS")
libcalamares.job.setprogress(0.3)

# build nixos-install command
nixosInstallCmd = [ "pkexec" ]
nixosInstallCmd.extend(generateProxyStrings())
nixosInstallCmd.extend(
[
"nixos-install",
"--no-root-passwd",
"--root",
root_mount_point
]
)

# Install customizations
try:
output = ""
proc = subprocess.Popen(
["pkexec", "nixos-install", "--no-root-passwd", "--root", root_mount_point],
nixosInstallCmd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
stderr=subprocess.STDOUT
)
while True:
line = proc.stdout.readline().decode("utf-8")
Expand Down

0 comments on commit 2d6e267

Please sign in to comment.