This commit is contained in:
Hadi 2024-06-25 21:57:24 +02:00
parent 6f6c8bebf7
commit c618feced4
11 changed files with 126 additions and 57 deletions

View File

@ -6,62 +6,73 @@
printf "\n\e[0;92m- \e[0m\e[1;77mNixy's Installation Script\e[0;96m [anotherhadi/nixy]\e[0m" printf "\n\e[0;92m- \e[0m\e[1;77mNixy's Installation Script\e[0;96m [anotherhadi/nixy]\e[0m"
# Check if we're on the good directory # Check if we're on the good directory
[[ -f "./docs/scripts/install.sh" ]] || (printf "\n\e[0;91mx \e[0m\e[1;77mNot in the project root directory\e[0m"; exit 1) [[ -f "./docs/scripts/install.sh" ]] || (
DIR=$(pwd) printf "\n\e[0;91mx \e[0m\e[1;77mNot in the project root directory\e[0m"
exit 1
)
DIR=$PWD
# Create a new configuration # Create a new configuration
read -p $'\n\e[0;92m+\e[0m\e[1;77m Username: \e[0;96m' username read -rp $'\n\e[0;92m+\e[0m\e[1;77m Username: \e[0;96m' username
read -p $'\n\e[0;92m+\e[0m\e[1;77m Hostname: \e[0;96m' hostname read -rp $'\n\e[0;92m+\e[0m\e[1;77m Hostname: \e[0;96m' hostname
HOST_DIR="./hosts/$hostname" HOST_DIR="./hosts/$hostname"
mkdir $HOST_DIR mkdir "$HOST_DIR"
nixos-generate-config # check that hardware-configuration.nix is indeed created and with user right nixos-generate-config --show-hardware-config >"$HOST_DIR/hardware-configuration.nix"
rm configuration.nix
mv hardware-configuration.nix "$HOST_DIR"
printf "\n\e[0;92m? \e[0m\e[1;77mInstall Nvidia drivers?\e[0;96m [y/N]\e[0m" printf "\n\e[0;92m? \e[0m\e[1;77mInstall Nvidia drivers?\e[0;96m [y/N]\e[0m"
read yn read -r yn
yn=$(echo "$yn" | tr '[:upper:]' '[:lower:]') yn=$(echo "$yn" | tr '[:upper:]' '[:lower:]')
if [[ $yn == "y" || $yn == "yes" ]]; then if [[ $yn == "y" || $yn == "yes" ]]; then
nvidia=true nvidia=true
else else
nvidia=false nvidia=false
fi fi
printf "\n\e[0;92m? \e[0m\e[1;77mInstall prime?\e[0;96m [y/N]\e[0m" printf "\n\e[0;92m? \e[0m\e[1;77mInstall prime?\e[0;96m [y/N]\e[0m"
read yn read -r yn
yn=$(echo "$yn" | tr '[:upper:]' '[:lower:]') yn=$(echo "$yn" | tr '[:upper:]' '[:lower:]')
if [[ $yn == "y" || $yn == "yes" ]]; then if [[ $yn == "y" || $yn == "yes" ]]; then
prime=true prime=true
else else
prime=false prime=false
fi fi
GUEST_CONFIG="./hosts/guest"
cp "$LAPTOP_CONFIG/configuration.nix" "$HOST_DIR/configuration.nix" cp "$LAPTOP_CONFIG/configuration.nix" "$HOST_DIR/configuration.nix"
cp "$LAPTOP_CONFIG/variables.nix" "$HOST_DIR/variables.nix" cp "$LAPTOP_CONFIG/variables.nix" "$HOST_DIR/variables.nix"
config=$(cat "$LAPTOP_CONFIG/configuration.nix") config=$(cat "$LAPTOP_CONFIG/configuration.nix")
if [[ $nvidia == false ]];then if [[ $nvidia == false ]]; then
config=$(echo "$config" | sed 's/..\/shared\/nvidia/# ..\/shared\/nvidia/') config=$(echo "$config" | sed 's/..\/shared\/nvidia/# ..\/shared\/nvidia/')
fi fi
if [[ $prime == false ]];then if [[ $prime == false ]]; then
config=$(echo "$config" | sed 's/..\/shared\/prime/# ..\/shared\/prime/') config=$(echo "$config" | sed 's/..\/shared\/prime/# ..\/shared\/prime/')
fi fi
echo "$config" >"$HOST_DIR/configuration.nix" echo "$config" >"$HOST_DIR/configuration.nix"
variables=$(cat "$LAPTOP_CONFIG/variables.nix") variables=$(cat "$LAPTOP_CONFIG/variables.nix")
variables=$(echo "$variables" | sed 's/112569860+anotherhadi@users.noreply.github.com/your_email/') variables=$(echo "$variables" | sed 's/112569860+anotherhadi@users.noreply.github.com/your_email/')
variables=$(echo "$variables" | sed 's/hadi/$username/') variables=$(echo "$variables" | sed "s/hadi/$username/")
variables=$(echo "$variables" | sed 's/nixy/$username/') # FIXME: Host name can be mixed with themes variables=$(echo "$variables" | sed "s/nixy/$hostname/") # FIXME: Host name can be mixed with themes
variables=$(echo "$variables" | sed 's/Hadi/your_username/') variables=$(echo "$variables" | sed "s/Hadi/$username/")
variables=$(echo "$variables" | sed 's/sops = true/sops = false/') variables=$(echo "$variables" | sed 's/sops = true/sops = false/')
variables=$(echo "$variables" | sed 's/obsidian = true/obsidian = false/') variables=$(echo "$variables" | sed 's/obsidian = true/obsidian = false/')
variables=$(echo "$variables" | sed 's/tailscale = true/tailscale = false/') variables=$(echo "$variables" | sed 's/tailscale = true/tailscale = false/')
echo "$variables" >"$HOST_DIR/variables.nix" echo "$variables" >"$HOST_DIR/variables.nix"
# printf "\n\e[0;92m✓ \e[0m\e[1;77mSucess Message\e[0m" # Add it to the git index
# printf "\n\e[0;92m+ \e[0m\e[1;77mAdded Message\e[0m" git add .
# printf "\n\e[0;92m? \e[0m\e[1;77mAn issue? Open an issue/pull request at : \e[0;96mhttps://github.com/anotherhadi/nixy \e[0m"
printf "\n\e[0;92m+ \e[0m\e[1;77mHost added!\e[0m"
# REBUILD
printf "\n\e[0;92m? \e[0m\e[1;77mDo you want to rebuild?\e[0;96m [y/N]\e[0m"
read -r yn
yn=$(echo "$yn" | tr '[:upper:]' '[:lower:]')
if [[ $yn == "y" || $yn == "yes" ]]; then
sudo nixos-rebuild switch --flake "$DIR"#"$hostname"
fi
printf "\n\e[0;92m✓ \e[0m\e[1;77mDone!\e[0m"

View File

@ -281,11 +281,11 @@
"xdph": "xdph" "xdph": "xdph"
}, },
"locked": { "locked": {
"lastModified": 1719324347, "lastModified": 1719338642,
"narHash": "sha256-hyvKFjeYOmikUr3A4DumBXGTFZSOj/1cIr1aj9w/AEo=", "narHash": "sha256-oy2IpTiMTof5rUqdmUMYzn6Xugc8kTh629soVCyC3L4=",
"ref": "refs/heads/main", "ref": "refs/heads/main",
"rev": "1d70962892a6e3e1cacd3663b390bbdf81426984", "rev": "95782de966ec9e182d49b2f032b74a1101f423e8",
"revCount": 4887, "revCount": 4889,
"submodules": true, "submodules": true,
"type": "git", "type": "git",
"url": "https://github.com/hyprwm/Hyprland" "url": "https://github.com/hyprwm/Hyprland"
@ -489,11 +489,11 @@
}, },
"nixpkgs_3": { "nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1719075281, "lastModified": 1719254875,
"narHash": "sha256-CyyxvOwFf12I91PBWz43iGT1kjsf5oi6ax7CrvaMyAo=", "narHash": "sha256-ECni+IkwXjusHsm9Sexdtq8weAq/yUyt1TWIemXt3Ko=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "a71e967ef3694799d0c418c98332f7ff4cc5f6af", "rev": "2893f56de08021cffd9b6b6dfc70fd9ccd51eb60",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -533,11 +533,11 @@
"treefmt-nix": "treefmt-nix" "treefmt-nix": "treefmt-nix"
}, },
"locked": { "locked": {
"lastModified": 1719326913, "lastModified": 1719334058,
"narHash": "sha256-pQxnJ2kTak6FuTIMy8hyQKiHpE/gqOx+8KZw2HXkcGs=", "narHash": "sha256-5uhWaoHhUYEPNC42NVW+srBgldwQKQE6dvW45rg0K3Q=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nixvim", "repo": "nixvim",
"rev": "7ac283f05074485c08aefe578a139e34d508edb9", "rev": "76a8790764ec983ca0659c952c4b6924c4e9bf1a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -548,11 +548,11 @@
}, },
"nur": { "nur": {
"locked": { "locked": {
"lastModified": 1719326701, "lastModified": 1719337524,
"narHash": "sha256-IDEPbakCvjk61uX19cnmSB8fsdFTmMe5Wt4bCyIUGdA=", "narHash": "sha256-bYp4//+XM+J1Y23sW6VjXAiCHUdq3aqgXue/tVeCxLw=",
"owner": "nix-community", "owner": "nix-community",
"repo": "NUR", "repo": "NUR",
"rev": "a331f41142ed524ce58ed0df1c72a7d0b13ec867", "rev": "37ae43594731d4d801f53dffe465006421c7c292",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -562,11 +562,11 @@
}, },
"nurpkgs": { "nurpkgs": {
"locked": { "locked": {
"lastModified": 1719326701, "lastModified": 1719337524,
"narHash": "sha256-IDEPbakCvjk61uX19cnmSB8fsdFTmMe5Wt4bCyIUGdA=", "narHash": "sha256-bYp4//+XM+J1Y23sW6VjXAiCHUdq3aqgXue/tVeCxLw=",
"owner": "nix-community", "owner": "nix-community",
"repo": "NUR", "repo": "NUR",
"rev": "a331f41142ed524ce58ed0df1c72a7d0b13ec867", "rev": "37ae43594731d4d801f53dffe465006421c7c292",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -11,6 +11,7 @@
./programs/nvim ./programs/nvim
./programs/qutebrowser ./programs/qutebrowser
./programs/spicetify ./programs/spicetify
./programs/zathura
# Scripts # Scripts
./scripts # All scripts ./scripts # All scripts
@ -25,6 +26,8 @@
./system/waybar ./system/waybar
./system/wlogout ./system/wlogout
./system/wofi ./system/wofi
./system/mime
./system/udiskie
]; ];
home = { home = {

View File

@ -0,0 +1,17 @@
# PDF viewer
{
programs.zathura = {
enable = true;
options = {
guioptions = "v";
adjust-open = "width";
statusbar-basename = true;
render-loading = false;
scroll-step = 120;
# highlight-color = ");
# highlight-active-color = mkForce (rgba "base0D");
};
};
}

View File

@ -0,0 +1,17 @@
{
xdg.mimeApps = {
enable = true;
defaultApplications = {
"text/markdown" = "nvim.desktop";
"text/plain" = "nvim.desktop";
"image/png" = "imv.desktop";
"image/jpeg" = "imv.desktop";
"image/gif" = "org.qutebrowser.qutebrowser.desktop";
"x-scheme-handler/http" = "org.qutebrowser.qutebrowser.desktop";
"x-scheme-handler/https" = "org.qutebrowser.qutebrowser.desktop";
"text/html" = "org.qutebrowser.qutebrowser.desktop";
"application/pdf" = "zathura.desktop";
};
};
}

View File

@ -6,6 +6,7 @@
./zoxide.nix ./zoxide.nix
./tmux.nix ./tmux.nix
./lazygit.nix ./lazygit.nix
./eza.nix
./fetch ./fetch
./lf ./lf
]; ];

13
home/system/shell/eza.nix Normal file
View File

@ -0,0 +1,13 @@
{
programs.eza = {
enable = true;
icons = true;
extraOptions = [
"--group-directories-first"
"--no-quotes"
"--git-ignore"
"--icons=always"
];
};
}

View File

@ -1,6 +1,6 @@
{ pkgs, lib, config, ... }: { { pkgs, lib, config, ... }: {
home.packages = with pkgs; [ eza bat ripgrep tldr ]; home.packages = with pkgs; [ bat ripgrep tldr ];
programs.zsh = { programs.zsh = {
enable = true; enable = true;
@ -42,8 +42,8 @@
celar = "clear"; celar = "clear";
e = "exit"; e = "exit";
cd = "z"; cd = "z";
ls = "${pkgs.eza}/bin/eza --icons=always"; ls = "eza --icons=always --no-quotes";
tree = "${pkgs.eza}/bin/eza --icons=always --tree"; tree = "eza --icons=always --tree --no-quotes";
sl = "ls"; sl = "ls";
open = "${pkgs.xdg_utils}/bin/xdg-open"; open = "${pkgs.xdg_utils}/bin/xdg-open";
icat = "${pkgs.kitty}/bin/kitty +kitten icat"; icat = "${pkgs.kitty}/bin/kitty +kitten icat";

View File

@ -0,0 +1,6 @@
{
services.udiskie = {
enable = true;
tray = "always";
};
}

View File

@ -5,6 +5,7 @@
../modules/nvidia.nix ../modules/nvidia.nix
../modules/prime.nix ../modules/prime.nix
../modules/tuigreet.nix ../modules/tuigreet.nix
../modules/usb.nix
./variables.nix ./variables.nix
]; ];

View File

@ -2,21 +2,21 @@
{ {
# USB Automounting # USB Automounting
services.gvfs.enable = true; # services.gvfs.enable = true;
# services.udisks2.enable = true; services.udisks2.enable = true;
# services.devmon.enable = true; # services.devmon.enable = true;
# Enable USB Guard # Enable USB Guard
services.usbguard = { # services.usbguard = {
enable = true; # enable = true;
dbus.enable = true; # dbus.enable = true;
implicitPolicyTarget = "block"; # implicitPolicyTarget = "block";
# FIXME: set yours pref USB devices (change {id} to your trusted USB device), use `lsusb` command (from usbutils package) to get list of all connected USB devices including integrated devices like camera, bluetooth, wifi, etc. with their IDs or just disable `usbguard` # # FIXME: set yours pref USB devices (change {id} to your trusted USB device), use `lsusb` command (from usbutils package) to get list of all connected USB devices including integrated devices like camera, bluetooth, wifi, etc. with their IDs or just disable `usbguard`
rules = '' # rules = ''
allow id {id} # device 1 # allow id {id} # device 1
allow id {id} # device 2 # allow id {id} # device 2
''; # '';
}; # };
# Enable USB-specific packages # Enable USB-specific packages
environment.systemPackages = with pkgs; [ usbutils ]; environment.systemPackages = with pkgs; [ usbutils ];