installer new users dir
This commit is contained in:
parent
4c4c3bd634
commit
abdcedec75
4 changed files with 35 additions and 4 deletions
|
@ -30,8 +30,8 @@
|
||||||
"x86_64-darwin"
|
"x86_64-darwin"
|
||||||
];
|
];
|
||||||
forAllSystems = nixpkgs.lib.genAttrs systems;
|
forAllSystems = nixpkgs.lib.genAttrs systems;
|
||||||
user = "nomad";
|
user = "nomad2";
|
||||||
hostname = "unkown";
|
hostname = "unkown2";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages =
|
packages =
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
monitor = [
|
monitor = [
|
||||||
"eDP-1,2560x1600@60,0x0,1.25"
|
"eDP-1,1920x1080@60,0x0,1"
|
||||||
"DP-2,1920x1080@60,auto,1"
|
"DP-2,1920x1080@60,auto,1"
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
{ user, ... }:
|
||||||
{
|
{
|
||||||
imports = [ ./nomad.nix ];
|
imports = [ ./${user}.nix ];
|
||||||
}
|
}
|
||||||
|
|
30
install.sh
30
install.sh
|
@ -18,6 +18,7 @@ $ENDCOLOR
|
||||||
echo
|
echo
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
|
||||||
# Define the flake file path
|
# Define the flake file path
|
||||||
flake_file="./flake.nix"
|
flake_file="./flake.nix"
|
||||||
config_file="./hosts/unkown/configuration.nix" # Specify the correct path for your host's configuration file
|
config_file="./hosts/unkown/configuration.nix" # Specify the correct path for your host's configuration file
|
||||||
|
@ -27,6 +28,35 @@ monitor_config_file="./home/nomad/unkown.nix"
|
||||||
read -p "Enter the new username: " new_user
|
read -p "Enter the new username: " new_user
|
||||||
read -p "Enter the new hostname: " new_hostname
|
read -p "Enter the new hostname: " new_hostname
|
||||||
|
|
||||||
|
if [ ! -f "./hosts/common/users/nomad.nix" ]; then
|
||||||
|
echo "Source file nomad.nix does not exist!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if the new file already exists
|
||||||
|
if [ -f "./hosts/common/users/$new_user.nix" ]; then
|
||||||
|
read -p "File $new_user.nix already exists. Overwrite? (y/n) " choice
|
||||||
|
if [ "$choice" != "y" ]; then
|
||||||
|
echo "Aborting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copy the file
|
||||||
|
echo "$YELLOW Creating user configuration for $new_user... $ENDCOLOR"
|
||||||
|
cp "./hosts/common/users/nomad.nix" "./hosts/common/users/$new_user.nix"
|
||||||
|
|
||||||
|
echo "$YELLOW Creating user home configuration for $new_user... $ENDCOLOR"
|
||||||
|
mkdir "./home/$new_user"
|
||||||
|
sleep 0.2
|
||||||
|
cp "./home/nomad/home.nix" "./home/$new_user/home.nix"
|
||||||
|
cp "./home/nomad/unkown.nix" "./home/$new_user/$new_hostname.nix"
|
||||||
|
cp -r "./home/nomad/dotfiles/" "./home/$new_user/"
|
||||||
|
|
||||||
|
echo "$GREEN User configuration for $new_user created successfully! $ENDCOLOR"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Replace the 'user' and 'hostname' values in the flake.nix file
|
# Replace the 'user' and 'hostname' values in the flake.nix file
|
||||||
sed -i "s/user = \".*\";/user = \"$new_user\";/" "$flake_file"
|
sed -i "s/user = \".*\";/user = \"$new_user\";/" "$flake_file"
|
||||||
sed -i "s/hostname = \".*\";/hostname = \"$new_hostname\";/" "$flake_file"
|
sed -i "s/hostname = \".*\";/hostname = \"$new_hostname\";/" "$flake_file"
|
||||||
|
|
Loading…
Reference in a new issue