Skip to content

Commit

Permalink
Substitute version in nix-installer.sh for release
Browse files Browse the repository at this point in the history
This will allos us to skip having to update version in an additional
file.
  • Loading branch information
mkenigs committed Dec 20, 2024
1 parent 03885d7 commit 02e7c47
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion assemble_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import tempfile
import tomllib

from string import Template

response = requests.get('https://hydra.nixos.org/jobset/experimental-nix-installer/experimental-installer/evals', headers={'Accept': 'application/json'})

evals = response.json()['evals']
Expand Down Expand Up @@ -56,7 +58,22 @@
release_files.append(installer_file)
print(f"Copying {installer_url} to {installer_file}")
shutil.copy(f"{installer_url}/bin/nix-installer", installer_file)
release_files.append("nix-installer.sh")

# Subsitute version in nix-installer.sh
original_file = "nix-installer.sh"

with open(original_file, "r") as nix_installer_sh:
nix_installer_sh_contents = nix_installer_sh.read()

template = Template(nix_installer_sh_contents)
updated_content = template.substitute(assemble_installer_templated_version=version)

# Write the modified content to the output file
substituted_file=f"{tmpdirname}/nix-installer.sh"
with open(substituted_file, "w", encoding="utf-8") as output_file:
output_file.write(updated_content)
release_files.append(substituted_file)

subprocess.run(
[
"gh",
Expand Down
2 changes: 1 addition & 1 deletion nix-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fi
set -u

# If NIX_INSTALLER_FORCE_ALLOW_HTTP is unset or empty, default it.
NIX_INSTALLER_BINARY_ROOT="${NIX_INSTALLER_BINARY_ROOT:-https://github.com/NixOS/experimental-nix-installer/releases/download/0.27.0}"
NIX_INSTALLER_BINARY_ROOT="${NIX_INSTALLER_BINARY_ROOT:-https://github.com/NixOS/experimental-nix-installer/releases/download/$assemble_installer_templated_version}"

main() {
downloader --check
Expand Down

0 comments on commit 02e7c47

Please sign in to comment.