Switch to home-manager instead of managing dotfiles manually

This commit is contained in:
2024-03-27 13:35:01 +00:00
parent f5fe3fe9c3
commit 4e25f86c98
10 changed files with 246 additions and 144 deletions

View File

@@ -1,31 +0,0 @@
#! /bin/bash
source ~/dotfiles/scripts/p.sh
source ~/dotfiles/scripts/color.sh
echo -e "${GREEN}[+] Updating...${ENDCOLOR}"
sudo paru -Syu
echo -e "${GREEN}[+] Cleaning orphaned (unneeded) packages...${ENDCOLOR}"
sudo paru -Rsn $(paru -Qdtq)
echo -e "${GREEN}[+] Cleaning old pacman cache...${ENDCOLOR}"
if p c pacman-contrib &>/dev/null; then
paccache -rk1
else
p i pacman-contrib
paccache -rk1
fi
echo -e "${GREEN}[+] Removing logs older than 7d...${ENDCOLOR}"
sudo journalctl --vacuum-time=7d
if p c flatpak &>/dev/null; then
echo -e "${GREEN}[+] Cleaning flatpak...:${ENDCOLOR}"
flatpak remove --unused
fi
echo -e "${GREEN}[i] AUR Packages installed:${ENDCOLOR}"
pacman -Qim | awk '/^Name/{name=$3} /^Installed Size/{print $4$5, name}' | sort -h
# Installed packages: pacman -Qen

View File

@@ -1,20 +0,0 @@
#! /bin/bash
source ~/dotfiles/scripts/color.sh
source ~/dotfiles/scripts/p.sh
echo -e "${GREEN}[+] Updating...${ENDCOLOR}"
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
echo -e "${GREEN}[+] Cleaning...${ENDCOLOR}"
sudo apt autoremove
sudo apt autoclean
echo -e "${GREEN}[+] Removing logs older than 7d...${ENDCOLOR}"
sudo journalctl --vacuum-time=7d
if p c flatpak &>/dev/null; then
echo -e "${GREEN}[+] Cleaning flatpak...:${ENDCOLOR}"
flatpak remove --unused
fi

211
home.nix Normal file
View File

@@ -0,0 +1,211 @@
# man home-configuration.nix
{ config, pkgs, ... }:
{
home.username = "trude";
home.homeDirectory = "/Users/trude"; #macOS
# home.homeDirectory = "/home/trude"; #Linux
home.stateVersion = "23.11"; # Do NOT change. This value stays the same when updating.
home.packages = with pkgs; [
# Packages to install:
vscode
obsidian
#signal-desktop
gnomeExtensions.vitals
# Override nerdfont to install JetBrains only.
(nerdfonts.override { fonts = [ "JetBrainsMono" ]; })
# Shel scripts:
(writeShellScriptBin "extract" ''
if [ -f $1 ]; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
'')
(writeShellScriptBin "update" ''
if [ "$(uname -s)" = "Darwin" ]; then
echo "Updating macOS..."
echo "THE DEVICE WILL RESTART IF NECESSARY."
sudo softwareupdate -iaR
else
if [ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]; then
echo "Updating Debian..."
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
sudo apt autoremove
sudo apt autoclean
sudo journalctl --vacuum-time=7d
elif [ "$(grep -Ei 'arch|manjaro|artix' /etc/*release)" ]; then
echo "Updating Arch..."
sudo pacman -Syu
sudo pacman -Rsn $(paru -Qdtq)
if p c pacman-contrib &>/dev/null; then
paccache -rk1
else
sudo pacman -S pacman-contrib
paccache -rk1
fi
sudo journalctl --vacuum-time=7d
else
echo "Unknown distro, skipping system update."
fi
fi
nix-channel --update
home-manager switch -b backup
'')
];
home.file = {
# ".screenrc".source = dotfiles/screenrc;
".config/nixpkgs/config.nix".text = ''
{ allowUnfree = true; }
'';
# ".gradle/gradle.properties".text = ''
# org.gradle.console=verbose
# org.gradle.daemon.idletimeout=3600000
# '';
};
home.sessionVariables = {
EDITOR = "code";
PS1 = ''\n[\[\e[37m\]\u\[\e[0m\]@\[\e[37;2m\]\h\[\e[0m\]] \[\e[1m\]\w \[\e[0;2m\]J:\[\e[0m\]\j\n\$ '';
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
gtk = {
enable = true;
gtk3.extraConfig = {
Settings = ''
gtk-application-prefer-dark-theme=1
'';
};
gtk4.extraConfig = {
Settings = ''
gtk-application-prefer-dark-theme=1
'';
};
};
# GNOME Settings
# Help: https://hoverbear.org/blog/declarative-gnome-configuration-in-nixos/
dconf.settings = {
# Use `dconf watch /` to track stateful changes you are doing, then set them here.
"org/gnome/shell" = {
disable-user-extensions = false;
# `gnome-extensions list` for a list
enabled-extensions = [
"Vitals@CoreCoding.com"
];
favorite-apps = [
"firefox.desktop"
"code.desktop"
"org.gnome.Terminal.desktop"
"org.gnome.Nautilus.desktop"
];
};
"org/gnome/desktop/interface" = {
color-scheme = "prefer-dark";
enable-hot-corners = false;
};
};
programs.git = {
enable = true;
userName = "TrudeEH";
userEmail = "ehtrude@gmail.com";
};
programs.bash = {
enable = true;
enableCompletion = true;
shellAliases = {
ls="ls --color=auto";
grep="grep --color=auto";
};
shellOptions = [
"completion-ignore-case on"
];
};
programs.vscode = {
enable = true;
enableUpdateCheck = false;
enableExtensionUpdateCheck = false;
mutableExtensionsDir = false;
# Extensions
extensions = (with pkgs.vscode-extensions; [
ms-vscode-remote.remote-ssh
mhutchie.git-graph
pkief.material-icon-theme
oderwat.indent-rainbow
bierner.emojisense
jnoortheen.nix-ide
ritwickdey.liveserver
github.vscode-pull-request-github
]);
# Settings
userSettings = {
# General
"editor.fontSize" = 12;
"editor.fontFamily" = "'JetBrainsMono Nerd Font', 'monospace', monospace";
"terminal.integrated.fontSize" = 10;
"terminal.integrated.fontFamily" = "'JetBrainsMono Nerd Font', 'monospace', monospace";
"window.zoomLevel" = 1;
"editor.multiCursorModifier" = "ctrlCmd";
"workbench.startupEditor" = "none";
"explorer.compactFolders" = false;
# Whitespace
"files.trimTrailingWhitespace" = true;
"files.trimFinalNewlines" = true;
"files.insertFinalNewline" = true;
"diffEditor.ignoreTrimWhitespace" = false;
# Git
"git.enableCommitSigning" = true;
"git-graph.repository.sign.commits" = true;
"git-graph.repository.sign.tags" = true;
"git-graph.repository.commits.showSignatureStatus" = true;
# Styling
"window.autoDetectColorScheme" = true;
"workbench.preferredDarkColorTheme" = "Default Dark Modern";
"workbench.preferredLightColorTheme" = "Default Light Modern";
"workbench.iconTheme" = "material-icon-theme";
"material-icon-theme.activeIconPack" = "none";
"material-icon-theme.folders.theme" = "classic";
"editor.fontLigatures" = true;
# Other
"telemetry.telemetryLevel" = "off";
"update.showReleaseNotes" = false;
};
};
}

View File

@@ -1,49 +0,0 @@
#
# ~/.bashrc
#
source ~/dotfiles/scripts/p.sh
alias ls='ls --color=auto'
alias grep='grep --color=auto'
PS1='\n[\[\e[37m\]\u\[\e[0m\]@\[\e[37;2m\]\h\[\e[0m\]] \[\e[1m\]\w \[\e[0;2m\]J:\[\e[0m\]\j\n\$ '
bind -s 'set completion-ignore-case on'
compress() {
FILE=$1
shift
case $FILE in
*.tar.bz2) tar cjf $FILE $* ;;
*.tar.gz) tar czf $FILE $* ;;
*.tgz) tar czf $FILE $* ;;
*.zip) zip $FILE $* ;;
*.rar) rar $FILE $* ;;
*) echo "Filetype not recognized" ;;
esac
}
extract() {
if [ -f $1 ]; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

View File

@@ -1,2 +0,0 @@
--enable-features=UseOzonePlatform
--ozone-platform=wayland

View File

@@ -1,3 +0,0 @@
{
allowUnfree = true;
}

View File

@@ -1,8 +0,0 @@
[user]
email = ehtrude@gmail.com
name = TrudeEH
[filter "lfs"]
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
clean = git-lfs clean -- %f

View File

@@ -1,9 +1,20 @@
#! /bin/bash #! /bin/bash
source scripts/p.sh detectDistro() {
source scripts/color.sh if [ "$(uname -s)" = "Darwin" ]; then
echo "macOS"
# ============== CONFIG ============== else
if [ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]; then
echo "Debian"
elif [ "$(grep -Ei 'arch|manjaro|artix' /etc/*release)" ]; then
echo "Arch"
else
echo 1
return 1
fi
fi
return 0
}
d=$(detectDistro) d=$(detectDistro)
if [[ $d == "Debian" ]]; then if [[ $d == "Debian" ]]; then
@@ -12,18 +23,28 @@ elif [[ $d == "Arch" ]]; then
sudo pacman -Sy curl sudo pacman -Sy curl
fi fi
echo -e "${GREEN}[+] Installing stow...${ENDCOLOR}" if ! nix --version &>/dev/null; then
p i stow echo -e "${YELLOW}[E] Nix not found.${ENDCOLOR}"
echo -e "${GREEN}[+] Installing the Nix package manager...${ENDCOLOR}"
# Link dotfile home to $HOME curl -L https://nixos.org/nix/install | sh
echo -e "${GREEN}[+] Symlinking dotfiles...${ENDCOLOR}" . $HOME/.nix-profile/etc/profile.d/nix.sh
stow -v -t $HOME home --adopt echo -e "${GREEN}[I] Installed Nix.${ENDCOLOR}"
git diff fi
git reset --hard
# Fix to add GUI nix-env apps to the GNOME launcher without having to restart # Fix to add GUI nix-env apps to the GNOME launcher without having to restart
ln -s "$HOME/.nix-profile/share/applications" "$HOME/.local/share/applications/nix-env" ln -s "$HOME/.nix-profile/share/applications" "$HOME/.local/share/applications/nix-env"
# ============== HOME MANAGER ==============
# Install font # Install
nix-env -iA nixpkgs.fira-code-nerdfont nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
nix-channel --update
nix-shell '<home-manager>' -A install
# Apply config
mkdir -p $HOME/.config/home-manager
rm $HOME/.config/home-manager/home.nix
ln -s $HOME/dotfiles/home.nix $HOME/.config/home-manager/home.nix
export NIXPKGS_ALLOW_UNFREE=1
home-manager switch -b backup

View File

@@ -1,16 +0,0 @@
RED="\e[31m"
GREEN="\e[32m"
YELLOW="\e[33m"
BLUE="\e[34m"
MAGENTA="\e[35m"
CYAN="\e[36m"
GRAY="\e[90m"
BOLD="\e[1m"
FAINT="\e[2m"
ITALIC="\e[3m"
UNDERLINE="\e[4m"
ENDCOLOR="\e[0m"
# Example usage: echo -e "${GRAY}Gray text${ENDCOLOR}"

View File

@@ -29,7 +29,6 @@ detectDistro() {
return 1 return 1
fi fi
fi fi
return 0
} }
oneline() { oneline() {