diff --git a/reinstall.sh b/reinstall.sh index 926dc37..5487b27 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash +# nixos 默认的配置不会生成 /bin/bash # shellcheck disable=SC2086 set -eE diff --git a/trans.sh b/trans.sh index 2fb51a2..acaf18f 100644 --- a/trans.sh +++ b/trans.sh @@ -891,9 +891,9 @@ EOF prefixLength = $prefix; } ]; - defaultGateway = { - address = "$ipv6_gateway"; - interface = "$ethx"; + defaultGateway6 = { + address = "$ipv6_gateway"; + interface = "$ethx"; }; EOF fi @@ -1133,10 +1133,27 @@ get_build_threads() { min $threads_by_ram $threads_by_core } +add_newline() { + # shellcheck disable=SC1003 + case "$1" in + head | start) sed -e '1s/^/\n/' ;; + tail | end) sed -e '$a\\' ;; + both) sed -e '1s/^/\n/' -e '$a\\' ;; + esac +} + install_nixos() { os_dir=/os keep_swap=true + show_nixos_config() { + echo + cat -n /os/etc/nixos/configuration.nix + echo + cat -n /os/etc/nixos/hardware-configuration.nix + echo + } + # 挂载分区,创建 swapfile mount_part_basic_layout /os /os/efi need_ram=2048 @@ -1191,10 +1208,12 @@ install_nixos() { # 添加 nix-env 安装的软件到 PATH PATH="/root/.nix-profile/bin:$PATH" - # 生成配置 + # 生成配置并显示 nixos-generate-config --root /os + echo "Original NixOS Configuration:" + show_nixos_config - # configuration.nix + # 修改 configuration.nix if is_efi; then nix_bootloader="boot.loader.efi.efiSysMountPoint = \"/efi\";" else @@ -1212,10 +1231,7 @@ install_nixos() { # TODO: 准确匹配网卡,添加 udev 或者直接配置 networkd 匹配 mac create_nixos_network_config /tmp/nixos_network_config.nix - # sed -e '1s/^/\n/' -e '$a\\' # 也可以在前后添加空行 - { - echo # 前面的空行 - cat <