adding install script
This commit is contained in:
118
install.sh
Normal file
118
install.sh
Normal file
@@ -0,0 +1,118 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# Use Nix to temporarily pull in Gum for a beautiful UI
|
||||
NIX_RUN="nix run --extra-experimental-features nix-command --extra-experimental-features flakes nixpkgs#gum --"
|
||||
|
||||
clear
|
||||
$NIX_RUN style --border double --margin "1" --padding "1 2" --border-foreground 212 "Nomarchy OS Bootstrap"
|
||||
echo "This script will generate your private downstream environment."
|
||||
echo ""
|
||||
|
||||
# 1. Gather User Information
|
||||
USERNAME=$($NIX_RUN input --placeholder "Enter your Linux username")
|
||||
HOSTNAME=$($NIX_RUN input --placeholder "Enter a hostname for this machine (e.g., nomarchy-sys)")
|
||||
|
||||
# 2. Setup the Local Directory
|
||||
LOCAL_DIR="$HOME/.nomarchy"
|
||||
echo "Creating local downstream repository at $LOCAL_DIR..."
|
||||
mkdir -p "$LOCAL_DIR"/{system,home,secrets}
|
||||
|
||||
# 3. Harvest the Hardware Configuration
|
||||
# A barebones install leaves this in /etc/nixos. We need it.
|
||||
echo "Copying hardware configuration..."
|
||||
sudo cp /etc/nixos/hardware-configuration.nix "$LOCAL_DIR/system/"
|
||||
sudo chown "$USER:users" "$LOCAL_DIR/system/hardware-configuration.nix"
|
||||
|
||||
# 4. Generate the Downstream Flake
|
||||
echo "Drafting your private flake.nix..."
|
||||
cat <<EOF > "$LOCAL_DIR/flake.nix"
|
||||
{
|
||||
description = "Private Downstream Machine Config (Nomarchy)";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";
|
||||
home-manager = {
|
||||
url = "github:nix-community/home-manager/release-25.11";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
# The Public Upstream Core
|
||||
nomarchy.url = \"git+https://git.bemagri.xyz/bernardo/Nomarchy.git\
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, home-manager, witness-os, ... }@inputs:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
targetUser = "$USERNAME";
|
||||
in {
|
||||
# THE SYSTEM DOMAIN
|
||||
nixosConfigurations."$HOSTNAME" = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
specialArgs = { inherit inputs; };
|
||||
modules = [
|
||||
./system/hardware-configuration.nix
|
||||
./system/configuration.nix
|
||||
nomarchy.nixosModules.system
|
||||
];
|
||||
};
|
||||
|
||||
# THE USER DOMAIN
|
||||
homeConfigurations."$USERNAME" = home-manager.lib.homeManagerConfiguration {
|
||||
pkgs = nixpkgs.legacyPackages."\${system}";
|
||||
extraSpecialArgs = { inherit inputs targetUser; };
|
||||
modules = [
|
||||
nomarchy.homeManagerModules.ui
|
||||
./home/home.nix
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
EOF
|
||||
|
||||
# 5. Generate the Scaffolding Files
|
||||
cat <<EOF > "$LOCAL_DIR/system/configuration.nix"
|
||||
{ pkgs, ... }: {
|
||||
networking.hostName = "$HOSTNAME";
|
||||
|
||||
# Add your private cryptography and C++ toolchains here later!
|
||||
environment.systemPackages = with pkgs; [ gcc cmake gdb ];
|
||||
}
|
||||
EOF
|
||||
|
||||
cat <<EOF > "$LOCAL_DIR/home/home.nix"
|
||||
{ ... }: {
|
||||
home.username = "$USERNAME";
|
||||
home.homeDirectory = "/home/$USERNAME";
|
||||
home.stateVersion = "25.11";
|
||||
|
||||
home.shellAliases = {
|
||||
update-sys = "sudo nixos-rebuild switch --flake ~/.nomarchy#$HOSTNAME";
|
||||
update-home = "nix run home-manager/release-25.11 -- switch --flake ~/.nomarchy#$USERNAME";
|
||||
};
|
||||
}
|
||||
EOF
|
||||
|
||||
# 6. Initialize Version Control
|
||||
echo "Initializing Git repository..."
|
||||
nix run nixpkgs#git -- -C "$LOCAL_DIR" init
|
||||
nix run nixpkgs#git -- -C "$LOCAL_DIR" add .
|
||||
|
||||
# 7. Execution
|
||||
clear
|
||||
$NIX_RUN style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Ready for Genesis"
|
||||
echo "Your private downstream configuration has been generated."
|
||||
|
||||
if $NIX_RUN confirm "Build Witness OS now? (This will take a few minutes)"; then
|
||||
echo "Building System Engine..."
|
||||
sudo nixos-rebuild switch --flake "$LOCAL_DIR#$HOSTNAME" --extra-experimental-features "nix-command flakes"
|
||||
|
||||
echo "Building User Interface..."
|
||||
nix run home-manager/release-25.11 -- switch --flake "$LOCAL_DIR#$USERNAME"
|
||||
|
||||
clear
|
||||
$NIX_RUN style --border double --margin "1" --padding "1 2" --border-foreground 212 "Installation Complete"
|
||||
echo "Welcome to Witness OS. Reboot to enter your new environment."
|
||||
else
|
||||
echo "Aborted. You can review your files in $LOCAL_DIR and run the build manually later."
|
||||
fi
|
||||
Reference in New Issue
Block a user