some updates

This commit is contained in:
Dmitriy Kholkin 2020-01-23 01:29:27 +00:00
parent b408364148
commit fa08060cf4
4 changed files with 17 additions and 12 deletions

View File

@ -1,4 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
CONFIG_FOLDER=$(pwd)/..
ENCRYPT_ROOT=true ENCRYPT_ROOT=true
ENCRYPT_SWAP=false ENCRYPT_SWAP=false
FORMAT_BOOT_PARTITION=false FORMAT_BOOT_PARTITION=false
@ -20,7 +22,7 @@ fi
# Create luks partition # Create luks partition
if [[ "$ENCRYPT_ROOT" == true ]]; then if [[ "$ENCRYPT_ROOT" == true ]]; then
cryptsetup --type luks2 --cipher aes-xts-plain64 --key-size 256 --hash sha512 luksFormat $ROOT_PARTITION cryptsetup --type luks2 --cipher aes-xts-plain64 --key-size 256 --hash sha512 luksFormat $ROOT_PARTITION
cryptsetup luksOpen $ROOT_PARTITION $ROOT_NAME cryptsetup luksOpen --type luks2 $ROOT_PARTITION $ROOT_NAME
ROOT_NAME=/dev/mapper/$ROOT_NAME ROOT_NAME=/dev/mapper/$ROOT_NAME
mkfs.btrfs -f -L root $ROOT_NAME mkfs.btrfs -f -L root $ROOT_NAME
mount -t btrfs -o compress=zstd,noatime,ssd $ROOT_NAME /mnt mount -t btrfs -o compress=zstd,noatime,ssd $ROOT_NAME /mnt
@ -51,6 +53,7 @@ mount $BOOT_PARTITION /mnt/boot
# read -p "Press enter to continue" # read -p "Press enter to continue"
# Create swap # Create swap
if [[ "$ENCRYPT_SWAP" == true ]]; then if [[ "$ENCRYPT_SWAP" == true ]]; then
mkdir -p /mnt/root
dd count=1 bs=256 if=/dev/urandom of=/mnt/root/swap.key dd count=1 bs=256 if=/dev/urandom of=/mnt/root/swap.key
cryptsetup --type luks2 --cipher aes-xts-plain64 --key-size 256 --hash sha512 --key-file /mnt/root/swap.key luksFormat $SWAP_PARTITION cryptsetup --type luks2 --cipher aes-xts-plain64 --key-size 256 --hash sha512 --key-file /mnt/root/swap.key luksFormat $SWAP_PARTITION
cryptsetup --key-file /mnt/root/swap.key luksOpen $SWAP_PARTITION $SWAP_NAME cryptsetup --key-file /mnt/root/swap.key luksOpen $SWAP_PARTITION $SWAP_NAME
@ -61,15 +64,17 @@ fi
# Generate config (hardware) # Generate config (hardware)
nixos-generate-config --root /mnt/ nixos-generate-config --root /mnt/
# Copy config to new system # Copy config to new system
mkdir -p /mnt/root/nixos-config # mkdir -p /mnt/root/nixos-config
cp -r $(pwd)/.. /mnt/root/nixos-config # cp -r $(pwd)/.. /mnt/root/nixos-config
echo "import /mnt/root/nixos-config \"$DEVICE_NAME\"" > /mnt/etc/nixos/configuration.nix echo "import $CONFIG_FOLDER \"$DEVICE_NAME\"" > /mnt/etc/nixos/configuration.nix
read -p "Debug" nano /mnt/etc/nixos/configuration.nix
# nano /mnt/etc/nixos/configuration.nix
sed -i 's/\/etc\/nixos/\/mnt\/etc\/nixos/g' /mnt/root/nixos-config/default.nix sed -i 's/\/etc\/nixos/\/mnt\/etc\/nixos/g' /mnt/root/nixos-config/default.nix
read -p "Please, add swap device into nixos-config/modules/filesystems.nix before continue" read -p "Please, add swap device into nixos-config/modules/filesystems.nix before continue"
read -p "Press enter to continue" read -p "Press enter to continue"
nixos-install -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz nixos-install -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz
sed -i 's/\/mnt\/etc\/nixos/\/etc\/nixos/g' /mnt/root/nixos-config/default.nix sed -i 's/\/mnt\/etc\/nixos/\/etc\/nixos/g' /mnt/root/nixos-config/default.nix
sed -i 's/\/mnt\/root/\/root/g' /mnt/etc/nixos/configuration.nix mkdir -p /mnt/home/alukard/nixos-config
read -p "Installation complete!" cp -r $CONFIG_FOLDER /mnt/home/alukard/nixos-config
chown -R alukard:users /mnt/home/alukard/nixos-config
# sed -i 's/\/mnt\/root/\/root/g' /mnt/etc/nixos/configuration.nix
# read -p "Installation complete!"

View File

@ -120,7 +120,7 @@ with deviceSpecific; {
device = if device == "AMD-Workstation" then device = if device == "AMD-Workstation" then
"/dev/disk/by-partuuid/3c4f9305-ad40-4ed3-b568-f1559f1c845a" "/dev/disk/by-partuuid/3c4f9305-ad40-4ed3-b568-f1559f1c845a"
else if device == "Dell-Laptop" then else if device == "Dell-Laptop" then
"/dev/disk/by-partuuid/2de40bc4-a91c-4c89-a2cd-cbf34a0adf01" "/dev/disk/by-partuuid/e979f198-37c4-4a86-8138-e148c3d78447"
else if device == "NixOS-VM" then else if device == "NixOS-VM" then
"/dev/disk/by-partuuid/4caf1e45-2f1c-4cb2-a914-f2e90961503a" "/dev/disk/by-partuuid/4caf1e45-2f1c-4cb2-a914-f2e90961503a"
else else

View File

@ -8,7 +8,7 @@ with deviceSpecific; {
enable = isLaptop; enable = isLaptop;
extraConfig = '' extraConfig = ''
# To avoid filesystem corruption on btrfs formatted partitions # To avoid filesystem corruption on btrfs formatted partitions
SATA_LINKPWR_ON_BAT=max_performance # SATA_LINKPWR_ON_BAT=max_performance
# Recommended # Recommended
CPU_SCALING_GOVERNOR_ON_AC=powersave CPU_SCALING_GOVERNOR_ON_AC=powersave
CPU_SCALING_GOVERNOR_ON_BAT=powersave CPU_SCALING_GOVERNOR_ON_BAT=powersave
@ -16,7 +16,7 @@ with deviceSpecific; {
CPU_HWP_ON_BAT=balance_power CPU_HWP_ON_BAT=balance_power
CPU_BOOST_ON_AC=1 CPU_BOOST_ON_AC=1
CPU_BOOST_ON_BAT=0 CPU_BOOST_ON_BAT=0
DISK_DEVICES="sda" DISK_DEVICES="sda nvme0n1"
DISK_APM_LEVEL_ON_AC="255 254" DISK_APM_LEVEL_ON_AC="255 254"
DISK_APM_LEVEL_ON_BAT="128 128" DISK_APM_LEVEL_ON_BAT="128 128"
''; '';

View File

@ -8,7 +8,7 @@
]; ];
}; };
services.mopidy = { services.mopidy = {
enable = true; enable = false;
extensionPackages = with pkgs; [ mopidy-local-sqlite ]; extensionPackages = with pkgs; [ mopidy-local-sqlite ];
configuration = '' configuration = ''
[local] [local]