Install using a flake
This commit is contained in:
parent
436d299588
commit
12f929d699
@ -21,7 +21,6 @@ _ = gettext.translation("calamares-python",
|
||||
languages=libcalamares.utils.gettext_languages(),
|
||||
fallback=True).gettext
|
||||
|
||||
def random_hostname():
|
||||
adjectives = [
|
||||
"autumn", "hidden", "bitter", "misty", "silent", "empty", "dry", "dark", "summer",
|
||||
"icy", "delicate", "quiet", "white", "cool", "spring", "winter", "patient",
|
||||
@ -48,14 +47,36 @@ def random_hostname():
|
||||
noun = secrets.choice(nouns)
|
||||
number = secrets.randbelow(10_000)
|
||||
|
||||
return f"{adjective}-{noun}-{number}"
|
||||
random_hostname = f"{adjective}-{noun}-{number}"
|
||||
|
||||
flake = f"""
|
||||
{{
|
||||
description = "deskOS flake";
|
||||
|
||||
inputs = {{
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
|
||||
}};
|
||||
|
||||
outputs = {{
|
||||
self,
|
||||
nixpkgs,
|
||||
}} @ inputs: {{
|
||||
nixosConfigurations.{random_hostname} = nixpkgs.lib.nixosSystem {{
|
||||
system = "x86_64-linux";
|
||||
specialArgs = {{inherit inputs;}};
|
||||
modules = [
|
||||
./configuration.nix
|
||||
];
|
||||
}};
|
||||
}};
|
||||
}}
|
||||
"""
|
||||
|
||||
configuration_head = """
|
||||
{ config, pkgs, ... }:
|
||||
{ pkgs, lib, inputs, ... }:
|
||||
|
||||
{
|
||||
imports =
|
||||
[
|
||||
imports = [
|
||||
./hardware-configuration.nix
|
||||
];
|
||||
"""
|
||||
@ -102,7 +123,7 @@ configuration_body = """
|
||||
"""
|
||||
|
||||
cfghostname = f"""
|
||||
networking.hostName = "{random_hostname()}";
|
||||
networking.hostName = "{random_hostname}";
|
||||
"""
|
||||
|
||||
cfgtime = """
|
||||
@ -189,6 +210,8 @@ def run():
|
||||
# Setup variables
|
||||
root_mount_point = gs.value("rootMountPoint")
|
||||
configFile = os.path.join(root_mount_point, "etc/nixos/configuration.nix")
|
||||
flakeFile = os.path.join(root_mount_point, "etc/nixos/flake.nix")
|
||||
flakePath = os.path.join(root_mount_point, "etc/nixos")
|
||||
|
||||
# Pick config parts and prepare substitution
|
||||
|
||||
@ -327,13 +350,17 @@ def run():
|
||||
libcalamares.utils.host_env_process_output(
|
||||
["cp", "/dev/stdin", configFile], None, cfg)
|
||||
|
||||
# Write the flake.nix file
|
||||
libcalamares.utils.host_env_process_output(
|
||||
["cp", "/dev/stdin", flakeFile], None, flake)
|
||||
|
||||
status = _("Installing Desk OS")
|
||||
libcalamares.job.setprogress(0.3)
|
||||
|
||||
# Install
|
||||
try:
|
||||
output = ""
|
||||
proc = subprocess.Popen(["pkexec", "nixos-install", "--no-root-passwd", "--root", root_mount_point], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
proc = subprocess.Popen(["pkexec", "nixos-install", "--no-root-passwd", "--flake", f"{flakePath}#{random_hostname}", "--root", root_mount_point], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
while True:
|
||||
line = proc.stdout.readline().decode("utf-8")
|
||||
output += line
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user