149 lines
4.9 KiB
Nix
149 lines
4.9 KiB
Nix
{ lib, pkgs, modulesPath, config, ... }:
|
||
|
||
{
|
||
imports = [
|
||
"${modulesPath}/installer/cd-dvd/installation-cd-minimal.nix"
|
||
];
|
||
|
||
networking.useDHCP = lib.mkDefault true;
|
||
time.timeZone = "Australia/Brisbane";
|
||
|
||
services.openssh.enable = true;
|
||
services.openssh.settings.PermitRootLogin = "yes";
|
||
|
||
environment.systemPackages = with pkgs; [
|
||
git curl parted e2fsprogs btrfs-progs util-linux
|
||
];
|
||
|
||
# environment.etc."flake-url".text = "git+https://gitea.lan.ddnsgeek.com/beatzaplenty/nixos.git?ref=main#nixos";
|
||
|
||
environment.etc."git-credentials".text =
|
||
"https://beatzaplenty:2b7e178eeee4af437fc721295d59e9e19366fd02@gitea.lan.ddnsgeek.com";
|
||
#programs.git.enable = true;
|
||
#programs.git.extraConfig."credential.helper" = "store --file=/etc/git-credentials";
|
||
programs.git = {
|
||
enable = true;
|
||
package = pkgs.git;
|
||
config = {
|
||
credential.helper = "store --file=/etc/git-credentials";
|
||
};
|
||
};
|
||
|
||
# Write auto-install script to /root
|
||
environment.etc."auto-install.sh".text = ''
|
||
#!/run/current-system/sw/bin/bash
|
||
set -eux
|
||
|
||
set -euo pipefail
|
||
|
||
export FLAKE_BASE_URL="git+https://gitea.lan.ddnsgeek.com/beatzaplenty/nixos.git"
|
||
|
||
# Menu options
|
||
options=("nixos" "docker" "server" "nix-cache" "nix-minimal")
|
||
|
||
echo "Choose the flake profile to install:"
|
||
select choice in "''${options[@]}"; do
|
||
if [[ -n "$choice" ]]; then
|
||
echo "You selected: $choice"
|
||
break
|
||
else
|
||
echo "Invalid selection. Try again."
|
||
fi
|
||
done
|
||
|
||
echo "Starting install with flake: ''${FLAKE_BASE_URL}#''${choice}"
|
||
|
||
# Optional: confirm before proceeding
|
||
read -rp "Proceed with installation? (y/N): " confirm
|
||
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
|
||
echo "Aborted."
|
||
exit 1
|
||
fi
|
||
|
||
|
||
parted -s /dev/sda -- mklabel msdos
|
||
parted -s /dev/sda -- mkpart primary 1MB -8GB
|
||
parted -s /dev/sda -- set 1 boot on
|
||
parted -s /dev/sda -- mkpart primary linux-swap -8GB 100%
|
||
mkfs.ext4 -L nixos /dev/sda1
|
||
mkswap -L swap /dev/sda2
|
||
swapon /dev/sda2
|
||
sleep 10
|
||
mount /dev/disk/by-label/nixos /mnt
|
||
mkdir -p /mnt/install-tmp
|
||
export TMPDIR=/mnt/install-tmp
|
||
nixos-install --flake "''${FLAKE_BASE_URL}#''${choice}" --no-root-password --no-write-lock-file
|
||
rm -rf /mnt/install-tmp
|
||
sleep 10
|
||
reboot
|
||
'';
|
||
# environment.etc."auto-install.sh".mode = "0755";
|
||
|
||
# Trigger the script from nixos user's shell
|
||
# environment.etc."nixos/.bashrc".text = ''
|
||
# # Run installer only once
|
||
# if [ -n "$PS1" ] && [ ! -e ~/.auto_install_ran ]; then
|
||
# sudo /etc/auto-install.sh
|
||
# touch ~/.auto_install_ran
|
||
# fi
|
||
# '';
|
||
# environment.etc."nixos/.bashrc".mode = "0755";
|
||
#Set root password
|
||
users.users.root = {
|
||
hashedPassword = "$6$Kwv9KAyvcurAViQF$H4.u3feqGE7lVoNgkFXhE3n2Pmo//9JYDTCz8ifrVHBxPjwa1xMby7tEZ8Bpt5MXs9Rkx6/YbZWxs5CpH0s/70";
|
||
};
|
||
|
||
# Define a user account. Don't forget to set a password with ‘passwd’.
|
||
users.users.nixos = {
|
||
isNormalUser = true;
|
||
extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
|
||
packages = with pkgs; [
|
||
tree
|
||
];
|
||
hashedPassword = "$6$Kwv9KAyvcurAViQF$H4.u3feqGE7lVoNgkFXhE3n2Pmo//9JYDTCz8ifrVHBxPjwa1xMby7tEZ8Bpt5MXs9Rkx6/YbZWxs5CpH0s/70";
|
||
openssh.authorizedKeys.keys = [
|
||
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCq/Q5LvIXlZwO2kdeAN5nLGZ59nZB7JHYMEszHxmNtGMzv1lM31jiPNsr0z2EKVZhE7OOfa2IF9rhWYD7JUA9G0yzdZ4WTXFNGVVOJoOVH6vAF3XCxoVilOEwTc7h2Wiy+rzd0B28/3spffzQQWJhY6GRQVa8j+6xAGF60Fcvl1vLosYT9Bn2ZbK4TCWOwAn2jqXIieGpZdn/UNZbGOeKRiCvhktDfMAzuQzN/9jMu/oF4pkPn2X1UrsQdNlvp0Ci8md612MozIpncQJyAF1ADhunr3sMx0isUXiqD29R5DS4TftpekqLNLak+zcxFa8N7DcRNp3DcKfJvyTkwQrR4r+b7lFLYOLHLagSso9CzeW/paAS2q9I5SBm/2DtE1diLLg2jZikYcstsu/G5RgvbzbKqjiaMwTdXC3AMvDxQrs7U5pDRZFzoofG3cpODbTm+uy3m0kP70z0M1K45UbDG0p+itnTu9x40JbQEgefbx38AItNvAIx1A8HO4I1VX28= wayne@stream"
|
||
];
|
||
home = "/home/nixos";
|
||
createHome = true;
|
||
shell = pkgs.bashInteractive;
|
||
|
||
};
|
||
# environment.etc."auto-install.sh".source = ./auto-install.sh;
|
||
environment.etc."auto-install.sh".mode = "0755";
|
||
|
||
# environment.etc."home/nixos/.bashrc".text = ''
|
||
# if [ -n "$PS1" ] && [ ! -e ~/.auto_install_ran ]; then
|
||
# sudo /etc/auto-install.sh
|
||
# touch ~/.auto_install_ran
|
||
# fi
|
||
# '';
|
||
# environment.etc."home/nixos/.bashrc".mode = "0644";
|
||
|
||
# Write .bashrc into the user's home directory
|
||
# environment.etc."bashrc-nixos".source = pkgs.writeText "bashrc-nixos" ''
|
||
# if [ -n "$PS1" ] && [ ! -e ~/.auto_install_ran ]; then
|
||
# sudo /etc/auto-install.sh
|
||
# touch ~/.auto_install_ran
|
||
# fi
|
||
# '';
|
||
|
||
system.activationScripts.installBashProfile = {
|
||
text = ''
|
||
mkdir -p /home/nixos
|
||
cp -f ${config.environment.etc."bash_profile-nixos".source} /home/nixos/.bash_profile
|
||
chown nixos:nixos /home/nixos/.bash_profile
|
||
chmod 644 /home/nixos/.bash_profile
|
||
'';
|
||
};
|
||
|
||
|
||
environment.etc."bash_profile-nixos".source = pkgs.writeText "bash_profile-nixos" ''
|
||
if [ -n "$PS1" ] && [ ! -e ~/.auto_install_ran ]; then
|
||
sudo /etc/auto-install.sh
|
||
touch ~/.auto_install_ran
|
||
fi
|
||
'';
|
||
|
||
}
|