mirror of
https://github.com/alyraffauf/nixcfg.git
synced 2024-11-24 09:51:54 -05:00
flake: add install script
This commit is contained in:
parent
7432c000e1
commit
cc615f0dbc
28
flake.nix
28
flake.nix
|
@ -45,6 +45,34 @@
|
||||||
"x86_64-linux"
|
"x86_64-linux"
|
||||||
] (system: inputs.nixpkgs.legacyPackages.${system}.alejandra);
|
] (system: inputs.nixpkgs.legacyPackages.${system}.alejandra);
|
||||||
|
|
||||||
|
packages."x86_64-linux".default = inputs.nixpkgs.legacyPackages."x86_64-linux".writeShellScriptBin "clean-install" ''
|
||||||
|
# Check if an argument is provided
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo "Error: Please provide a flake as an argument."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Construct the flake input
|
||||||
|
FLAKE_INPUT=$1
|
||||||
|
|
||||||
|
# Display a warning message
|
||||||
|
echo "Warning: Running this script will wipe the currently installed system."
|
||||||
|
read -p "Do you want to continue? (y/n): " answer
|
||||||
|
|
||||||
|
# Check the user's response
|
||||||
|
if [ "$answer" != "y" ]; then
|
||||||
|
echo "Aborted."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run the nix command with the updated flake input
|
||||||
|
sudo nix --experimental-features "nix-command flakes" run \
|
||||||
|
github:nix-community/disko -- --mode disko --flake $FLAKE_INPUT
|
||||||
|
|
||||||
|
# Install NixOS with the updated flake input and root settings
|
||||||
|
sudo nixos-install --no-root-password --root /mnt --flake $FLAKE_INPUT
|
||||||
|
'' ;
|
||||||
|
|
||||||
nixosModules.default =
|
nixosModules.default =
|
||||||
import ./nixosModules inputs;
|
import ./nixosModules inputs;
|
||||||
|
|
||||||
|
|
44
install.sh
44
install.sh
|
@ -1,44 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
# Copyright 2024 Aly Raffauf
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it
|
|
||||||
# and/or modify it under the terms of the GNU General Public
|
|
||||||
# License as published by the Free Software Foundation, either
|
|
||||||
# version 3 of the License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
# General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
# Automatically partitions drive and installs NixOS from a given flake,
|
|
||||||
# provided your flake includes a valid disko configuration.
|
|
||||||
|
|
||||||
# Check if an argument is provided
|
|
||||||
if [ $# -eq 0 ]; then
|
|
||||||
echo "Error: Please provide a flake as an argument."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Construct the flake input
|
|
||||||
FLAKE_INPUT=$1
|
|
||||||
|
|
||||||
# Display a warning message
|
|
||||||
echo "Warning: Running this script will wipe the currently installed system."
|
|
||||||
read -p "Do you want to continue? (y/n): " answer
|
|
||||||
|
|
||||||
# Check the user's response
|
|
||||||
if [ "$answer" != "y" ]; then
|
|
||||||
echo "Aborted."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run the nix command with the updated flake input
|
|
||||||
sudo nix --experimental-features "nix-command flakes" run \
|
|
||||||
github:nix-community/disko -- --mode disko --flake $FLAKE_INPUT
|
|
||||||
|
|
||||||
# Install NixOS with the updated flake input and root settings
|
|
||||||
sudo nixos-install --no-root-password --root /mnt --flake $FLAKE_INPUT
|
|
Loading…
Reference in a new issue