This commit is contained in:
Dmitriy Kholkin 2022-09-29 18:53:46 +03:00
parent 092d5695c1
commit 6222bc290d
8 changed files with 142 additions and 76 deletions

54
flake.lock generated
View File

@ -275,11 +275,11 @@
"utils": "utils_2"
},
"locked": {
"lastModified": 1663835995,
"narHash": "sha256-XNHQ+mdHbjNR1Oit00SFAEcrAZoCS08E7uAFcVMtwhM=",
"lastModified": 1663932797,
"narHash": "sha256-IH8ZBW99W2k7wKLS+Sat9HiKX1TPZjFTnsPizK5crok=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "bd83eab6220226085c82e637931a7ae3863d9893",
"rev": "de3758e31a3a1bc79d569f5deb5dac39791bf9b6",
"type": "github"
},
"original": {
@ -296,11 +296,11 @@
"wlroots": "wlroots"
},
"locked": {
"lastModified": 1663866803,
"narHash": "sha256-wfhZ//vxhipvF9n9f+s4W0Ql35B5IsLiO5cYAqbxIDQ=",
"lastModified": 1663953535,
"narHash": "sha256-bGIIXSdEpkw1XWuOeJZtF4f8/EEo1HghNAQPaY+EKCg=",
"owner": "hyprwm",
"repo": "Hyprland",
"rev": "ef3eb37c7f2cdbbab23e611aedc438c317463ef8",
"rev": "959557ecc35ed8708facf979f5b255b80885a50a",
"type": "github"
},
"original": {
@ -370,11 +370,11 @@
]
},
"locked": {
"lastModified": 1661448932,
"narHash": "sha256-0Ryhy6w3f8AhQn5ZllCt6+6t5+ky5PtTesslMXFjLUw=",
"lastModified": 1659964474,
"narHash": "sha256-PK8yYgRg7IG07Town2pVWB0tmtBBzIXtX5pqssHW6B4=",
"owner": "lourkeur",
"repo": "miniguest",
"rev": "6182fb1f074efe16bdab59b159e910c81b165e2f",
"rev": "dd5c5ef2dc4933bcb0504d7120c410219de607e2",
"type": "github"
},
"original": {
@ -546,11 +546,11 @@
},
"nixpkgs-master": {
"locked": {
"lastModified": 1663867771,
"narHash": "sha256-4vu3CatfxujbDX6FkHhY29Q1bFzjo/uvsWLa83MZx8w=",
"lastModified": 1663957247,
"narHash": "sha256-LKzVntuuwkXGezUnxTTYG5NlxYUTFFmMPe/EshDQAgc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "a22f7345336c7bbb785d3525c6760c5391c3171f",
"rev": "05914af3e0b0a358abf23bb4d80853acc4861b07",
"type": "github"
},
"original": {
@ -594,11 +594,11 @@
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1663760840,
"narHash": "sha256-ym5Iycs5H4cOaLfE2/vC0tsLp8XuBJQIHGV8/uXSy8M=",
"lastModified": 1663855239,
"narHash": "sha256-A2B7rlFKmBikRwz/cmayWcTAhyIOdp2whjVCDGhg9Xw=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "9bdbbaa634aa666eb6a27096bdcb991c59181244",
"rev": "bcc68429a50c4ac051920c72c60e417202c19d79",
"type": "github"
},
"original": {
@ -618,11 +618,11 @@
]
},
"locked": {
"lastModified": 1663787477,
"narHash": "sha256-gk4hht7ukjipy5Xw6glCwgCY3nNqQxrsNLsj6PxtDe0=",
"lastModified": 1663957741,
"narHash": "sha256-iAV7vaPsPIbJ4+dShe9VNdjOeIcMlMKtlnqpSvC9iz0=",
"owner": "nix-community",
"repo": "nixpkgs-wayland",
"rev": "3c06306de01e463b09e88d312bfe17971aaadb9d",
"rev": "007dde17cf749db8e78cb9f2e74c562483b06e60",
"type": "github"
},
"original": {
@ -665,11 +665,11 @@
},
"nixpkgs_4": {
"locked": {
"lastModified": 1663761423,
"narHash": "sha256-bDLXl2BVq7eIQz/8CduZI1SLyhG9u/CrckHd6f7bwPE=",
"lastModified": 1663850217,
"narHash": "sha256-tp9nXo1/IdN/xN9m06ryy0QUAEfoN6K56ObM/1QTAjc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "d6490a0bd9dfb298fcd8382d3363b86870dc7340",
"rev": "ae1dc133ea5f1538d035af41e5ddbc2ebcb67b90",
"type": "github"
},
"original": {
@ -681,11 +681,11 @@
},
"nur": {
"locked": {
"lastModified": 1663871140,
"narHash": "sha256-1HLjTL67ubOdPnIyECioP9TPNtL+NuxlY9D/qHpk7rA=",
"lastModified": 1663955967,
"narHash": "sha256-Ohl1Cnf6Dv9QmZNq5grMV1fV4srTtHIO6wwtTsQFshw=",
"owner": "nix-community",
"repo": "NUR",
"rev": "a643ef20f4722ae40f8949be4c453271172be25a",
"rev": "bc25b7916941f381a0a1a3b2a8659422f2d7aab1",
"type": "github"
},
"original": {
@ -806,11 +806,11 @@
"rycee": {
"flake": false,
"locked": {
"lastModified": 1663819364,
"narHash": "sha256-+dv4D+C2NRS6OnzfAvxYbE9GA65FhZQ0E+biMtHWDNo=",
"lastModified": 1663933333,
"narHash": "sha256-h4m8WDfnR0OrdAbMagzAPA7ENBJ+0WL33mtb3EeIcFI=",
"owner": "rycee",
"repo": "nur-expressions",
"rev": "7f27fc9880250a0eaf6386aa93286198ceaecbe0",
"rev": "4c461713bc88c297fae426b0fb63a0d459e869fb",
"type": "gitlab"
},
"original": {

View File

@ -89,9 +89,9 @@
if [[ -z $1 ]]; then
echo "Usage: $(basename $0) {switch|boot|test}"
elif [[ $1 = "iso" ]]; then
nix build .#nixosConfigurations.Flakes-ISO.config.system.build.isoImage
nix build .#nixosConfigurations.Flakes-ISO.config.system.build.isoImage "$@"
else
sudo nixos-rebuild $1 --flake .
sudo nixos-rebuild $1 --flake . "$@"
fi
'');
update-vscode = (pkgs: pkgs.writeShellScriptBin "update-vscode" ''

94
install/install-zsh.sh → install/install-zfs.sh Normal file → Executable file
View File

@ -1,15 +1,14 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p perl -p gptfdisk -p parted
#! nix-shell -i bash -p perl -p gptfdisk -p parted -p git
set -e
CONFIG_FOLDER="$(dirname "$(pwd)")"
DEVICE_NAME=NixOS-VM
MAX_JOBS=4
SWAP_SIZE=2GiB
NIXOS_COMMIT="84917aa00bf23c88e5874c683abe05edb0ba4078"
DEVICE_NAME=AMD-Workstation
MAX_JOBS=8
SWAP_SIZE=16GiB
USE_ECNRYPTION=false
ZFS_ARC_MAX=1073741824 # Max ARC cache size. default = 4GiB
ZFS_ARC_MAX=8589934592
# ZFS_ARC_MAX=4294967296 # Max ARC cache size. default = 4GiB
ZFS_ASHIFT=12 # recommended=12 which 1<<12 (4096)
@ -56,7 +55,7 @@ create_new_part_table() {
sgdisk -n 3 -t 3:8309 "$DISK"
else
pprint "Creating ROOT partition"
sgdisk -n 3 -t 3:8300 "$DISK"
sgdisk -n 3 -t 3:BF00 "$DISK"
fi
LINUX="$DISK-part3"
@ -158,42 +157,50 @@ if [[ "$SWAP" != "NONE" ]]; then
fi
pprint "Create ZFS pool on $ZFS"
zpool create -f -m none -o ashift=$ZFS_ASHIFT -O compression=lz4 -O normalization=formD -O atime=on -O relatime=on -O dedup=off -O com.sun:auto-snapshot=true -R /mnt rpool "$ZFS"
zpool create \
-f \
# -m none \
-o ashift=$ZFS_ASHIFT \
-o autotrim=on \
-R /mnt \
-O acltype=posixacl \
-O atime=on \
-O canmount=off \
-O compression=zstd \
-O dnodesize=auto
-O normalization=formD \
-O relatime=on \
-O xattr=sa \
-O dedup=off \
# -O com.sun:auto-snapshot=true \
-O mountpoint=/ \
rpool "$ZFS"
pprint "Create ZFS datasets"
zfs create -o mountpoint=none rpool/local
zfs create -o mountpoint=legacy -o com.sun:auto-snapshot=false -o atime=off -o recordsize=16K rpool/local/bittorrent
zfs create -o mountpoint=legacy -o com.sun:auto-snapshot:frequent=false -o com.sun:auto-snapshot:monthly=false -o atime=off rpool/local/nix
zfs create -o mountpoint=legacy -o xattr=sa -o atime=off -o recordsize=8K -o com.sun:auto-snapshot:frequent=false rpool/local/libvirt
zfs create -o mountpoint=none -o com.sun:auto-snapshot:frequent=false rpool/system
zfs create -o mountpoint=legacy rpool/system/root
zfs create -o mountpoint=legacy -o xattr=sa -o acltype=posixacl rpool/system/var
zfs create -o mountpoint=none rpool/user
zfs create -o mountpoint=legacy rpool/user/home
zfs create -o canmount=off -o mountpoint=none rpool/nixos
zfs create -o canmount=off -o mountpoint=none rpool/user
zfs create -o canmount=on -o mountpoint=/ rpool/nixos/root
zfs create -o canmount=noauto -o mountpoint=/ rpool/nixos/empty
zfs create -o canmount=on -o mountpoint=/nix rpool/nixos/nix
zfs create -o canmount=on -o mountpoint=/home rpool/user/home
zfs create -o canmount=off -o mountpoint=/var rpool/nixos/var
zfs create -o canmount=on rpool/nixos/var/lib
zfs create -o canmount=on rpool/nixos/var/log
zfs create -o canmount=on -o mountpoint=/media/bittorrent -o atime=off -o recordsize=256K rpool/nixos/bittorrent
zfs create -o canmount=on -o mountpoint=/media/libvirt -o atime=off -o recordsize=64K rpool/nixos/libvirt
# Create blank zfs snapshot
zfs snapshot rpool/local@blank
zfs snapshot rpool/system@blank
zfs snapshot rpool/nixos@blank
zfs snapshot rpool/user@blank
zfs snapshot rpool/nixos/empty@start
pprint "Mount ZFS datasets"
mount -t zfs rpool/system/root /mnt
mkdir /mnt/nix
mount -t zfs rpool/local/nix /mnt/nix
mkdir /mnt/var
mount -t zfs rpool/system/var /mnt/var
mkdir /mnt/home
mount -t zfs rpool/user/home /mnt/home
mkdir -p /mnt/home/alukard/.libvirt
chown -R 1000:100 /mnt/home/alukard
mount -t zfs rpool/local/libvirt /mnt/home/alukard/.libvirt
mkdir /mnt/bittorrent
mount -t zfs rpool/local/bittorrent /mnt/bittorrent
# Disable cache, stale cache will prevent system from booting
mkdir -p /mnt/etc/zfs/
rm -f /mnt/etc/zfs/zpool.cache
touch /mnt/etc/zfs/zpool.cache
chmod a-w /mnt/etc/zfs/zpool.cache
chattr +i /mnt/etc/zfs/zpool.cache
mkdir /mnt/boot
mount "$BOOT" /mnt/boot
@ -212,6 +219,7 @@ if [[ "$USE_ECNRYPTION" = true ]]
then
cat <<CONFIG > "$HARDWARE_CONFIG"
networking.hostId = "$HOSTID";
boot.kernelParams = [ "nohibernate" ];
boot.initrd.luks.devices."$LUKS_DEVICE_NAME".device = "/dev/disk/by-partuuid/$LINUX_DISK_UUID";
boot.zfs.devNodes = "$ZFS";
boot.supportedFilesystems = [ "zfs" ];
@ -220,6 +228,7 @@ CONFIG
else
cat <<CONFIG > "$HARDWARE_CONFIG"
networking.hostId = "$HOSTID";
boot.kernelParams = [ "nohibernate" ];
boot.zfs.devNodes = "$ZFS";
boot.supportedFilesystems = [ "zfs" ];
boot.kernelParams = [ "zfs.zfs_arc_max=$ZFS_ARC_MAX" ];
@ -228,24 +237,25 @@ fi
pprint "Append ZFS configuration to hardware-configuration.nix"
sed -i "\$e cat $HARDWARE_CONFIG" /mnt/etc/nixos/hardware-configuration.nix
sed -i 's|fsType = "zfs";|fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];|g' /mnt/etc/nixos/hardware-configuration.nix
if [[ "$SWAP" != "NONE" ]]; then
perl -0777 -pi -e "s#swapDevices.+#swapDevices = [\n {\n device = \"/dev/disk/by-partuuid/$SWAP_UUID\";\n randomEncryption.enable = true;\n }\n ];#" /mnt/etc/nixos/hardware-configuration.nix
fi
pprint "Copy minimal config to destination system"
pprint "Copy hardware config to machines folder"
cp /mnt/etc/nixos/hardware-configuration.nix $CONFIG_FOLDER/machines/$DEVICE_NAME/hardware-configuration.nix
chown 1000:users ../machines/$DEVICE_NAME/hardware-configuration.nix
# Change <not-detected> for flakes
sed -i 's#<nixpkgs/nixos/modules/installer/scan/not-detected.nix>#"${inputs.nixpkgs}/nixos/modules/installer/scan/not-detected.nix"#' $CONFIG_FOLDER/machines/$DEVICE_NAME/hardware-configuration.nix
cp ./min-config.nix /mnt/etc/nixos/configuration.nix
sed -i "s#changeme#${DEVICE_NAME}#" /mnt/etc/nixos/configuration.nix
sed -i "s#<nixpkgs/nixos/modules/installer/scan/not-detected.nix>#\"\${inputs.nixpkgs}/nixos/modules/installer/scan/not-detected.nix\"#" $CONFIG_FOLDER/machines/$DEVICE_NAME/hardware-configuration.nix
git add -A
clean_stdin
read -p "> Do you want to execute nixos-install command?" -n 1 -r
echo
if [[ "$REPLY" =~ ^[Yy]$ ]]
then
nixos-install -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/$NIXOS_COMMIT.tar.gz --max-jobs $MAX_JOBS --no-root-passwd
nixos-install --flake "../#$DEVICE_NAME" --max-jobs $MAX_JOBS --no-root-passwd --impure
fi
pprint "Copy config to destination system"

View File

@ -0,0 +1,32 @@
{ inputs, config, lib, pkgs, ... }: {
imports = [
"${modulesPath}/profiles/qemu-guest.nix"
./hardware-configuration.nix
inputs.self.nixosRoles.desktop
];
deviceSpecific.devInfo = {
cpu = {
vendor = "amd";
clock = 3700;
cores = 2;
};
drive = {
type = "ssd";
speed = 2000;
size = 30;
};
gpu = {
vendor = "other";
};
bigScreen = false;
ram = 4;
};
deviceSpecific.isHost = true;
deviceSpecific.isShared = false;
deviceSpecific.isGaming = false;
deviceSpecific.enableVirtualisation = false;
deviceSpecific.wireguard.enable = false;
hardware.video.hidpi.enable = lib.mkForce false;
}

View File

@ -0,0 +1 @@
x86_64-linux

View File

@ -86,7 +86,7 @@ in {
"general.autoScroll" = true;
"extensions.pocket.enabled" = false;
"browser.startup.page" = 1;
"browser.startup.homepage" = "https://organizr.ataraxiadev.com";
"browser.startup.homepage" = "https://startpage.ataraxiadev.com";
"toolkit.legacyUserProfileCustomizations.stylesheets" = true;
"browser.search.suggest.enabled" = true;
"ui.context_menus.after_mouseup" = true;
@ -126,7 +126,7 @@ in {
"signon.rememberSignons" = false;
"general.autoScroll" = true;
"extensions.pocket.enabled" = false;
"browser.startup.homepage" = "https://organizr.ataraxiadev.com";
"browser.startup.homepage" = "https://startpage.ataraxiadev.com";
"toolkit.legacyUserProfileCustomizations.stylesheets" = true;
"browser.search.suggest.enabled" = true;
"browser.urlbar.suggest.searches" = true;
@ -135,9 +135,9 @@ in {
"media.eme.enabled" = true;
"browser.startup.page" = 3;
"network.cookie.lifetimePolicy" = 0;
"browser.sessionstore.privacy_level" = 0;
"privacy.clearOnShutdown.history" = false;
"privacy.clearOnShutdown.cookies" = false;
"privacy.cpd.history" = false;
"font.name.monospace.x-western" = "${fonts.mono.family}";

View File

@ -72,6 +72,27 @@
];
};
environment.etc = {
"wireplumber/bluetooth.lua.d/51-bluez-config.lua".text = ''
bluez_monitor.properties = {
["bluez5.enable-sbc-xq"] = true,
["bluez5.enable-msbc"] = true,
["bluez5.hw-volume"] = "[ hfp_ag hsp_ag a2dp_source a2dp_sink ]",
["bluez5.headset-roles"] = "[ hsp_hs hsp_ag hfp_hf hfp_ag a2dp_sink ]",
["bluez5.reconnect-profiles"] = "[ hsp_hs hfp_hf a2dp_sink ]",
}
'';
};
home-manager.users.alukard.xdg.configFile."wireplumber/bluetooth.lua.d/51-bluez-config.lua".text = ''
bluez_monitor.properties = {
["bluez5.enable-sbc-xq"] = true,
["bluez5.enable-msbc"] = true,
["bluez5.hw-volume"] = "[ hfp_ag hsp_ag a2dp_source a2dp_sink ]",
["bluez5.headset-roles"] = "[ hsp_hs hsp_ag hfp_hf hfp_ag a2dp_sink ]",
["bluez5.reconnect-profiles"] = "[ hsp_hs hfp_hf a2dp_sink ]",
}
'';
security.rtkit.enable = true;
home-manager.users.alukard.home.packages = [ pkgs.pavucontrol pkgs.pulseaudio ];

View File

@ -76,12 +76,11 @@ in with config.deviceSpecific; with lib; {
''}
general {
${if config.device == "AMD-Workstation" then ''
sensitivity=0.7
sensitivity=0.65
'' else ''
sensitivity=1.3
''}
apply_sens_to_raw=false
main_mod=${modifier}
border_size=1
no_border_on_floating=false
gaps_in=6
@ -144,6 +143,9 @@ in with config.deviceSpecific; with lib; {
col.group_border_active=0xAA${thm.base08-hex}
}
'' ''
bindm=${modifier},mouse:272,movewindow
bindm=${modifier},mouse:273,resizewindow
bind=${modifier},q,killactive,
bind=${modifier},f,fullscreen,0
bind=${modifier}SHIFT,F,togglefloating,