From 57580dbdb0f1ccb41e72b9b804ca150b7e35d86a Mon Sep 17 00:00:00 2001 From: Bernardo Magri Date: Fri, 10 Apr 2026 18:51:01 +0100 Subject: [PATCH] adding install script --- install.sh | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 install.sh diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..f94f1ff --- /dev/null +++ b/install.sh @@ -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 < "$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 < "$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 < "$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 \ No newline at end of file