aboutsummaryrefslogtreecommitdiff
path: root/nix/systems/installer/default.nix
diff options
context:
space:
mode:
authorPreston Pan <ret2pop@gmail.com>2025-01-16 02:11:26 -0800
committerPreston Pan <ret2pop@gmail.com>2025-01-16 02:11:26 -0800
commit1a3486d77574c06b395ab6cda41084f5ed24a3f4 (patch)
tree69d1051bd14a0c3cb374f84a8c06cb655eba509b /nix/systems/installer/default.nix
parent2dff9d2b61244fed49136028d0e0f6ae3ae759cf (diff)
modularized nix configuration; builds correctly
Diffstat (limited to 'nix/systems/installer/default.nix')
-rw-r--r--nix/systems/installer/default.nix55
1 files changed, 55 insertions, 0 deletions
diff --git a/nix/systems/installer/default.nix b/nix/systems/installer/default.nix
new file mode 100644
index 0000000..62018a0
--- /dev/null
+++ b/nix/systems/installer/default.nix
@@ -0,0 +1,55 @@
+{ pkgs, config, ... }:
+let
+ commits = ./commits.nix;
+in
+{
+ imports = [
+ ../../modules/default.nix
+ ];
+
+ monorepo.profiles.home.enable = false;
+ monorepo.vars.userName = "nixos";
+
+ users.extraUsers.root.password = "nixos";
+ users.users = {
+ "${config.monorepo.vars.userName}" = {
+ packages = with pkgs; [
+ gum
+ (writeShellScriptBin "nix_installer"
+ ''
+#!/usr/bin/env bash
+
+set -euo pipefail
+if [ "$(id -u)" -eq 0 ]; then
+ echo "ERROR! $(basename "$0") should be run as a regular user"
+ exit 1
+fi
+ping -q -c1 google.com &>/dev/null && echo "online! Proceeding with the installation..." || nmtui
+cd
+if [ ! -d "$HOME/toughnix/" ]; then
+ git clone https://git.nullring.xyz/monorepo.git
+ cd monorepo
+ git checkout "${commits.monorepoCommitHash}"
+fi
+vim "$HOME/monorepo/nix/modules/default.nix"
+vim "$HOME/monorepo/nix/modules/vars.nix"
+sudo nix --experimental-features "nix-command flakes" run "github:nix-community/disko/${commits.diskoCommitHash}" -- --mode destroy,format,mount "$HOME/monorepo/nix/systems/desktop/sda-simple.nix"
+cd /mnt
+sudo nixos-install --flake $HOME/monorepo/nix#continuity
+sudo cp $HOME/monorepo "/mnt/home/$(ls /mnt/home/)/"
+echo "rebooting..."; sleep 3; reboot
+'')
+ ];
+ };
+ };
+
+ systemd = {
+ services.sshd.wantedBy = pkgs.lib.mkForce ["multi-user.target"];
+ targets = {
+ sleep.enable = false;
+ suspend.enable = false;
+ hibernate.enable = false;
+ hybrid-sleep.enable = false;
+ };
+ };
+}