Compare commits

..

No commits in common. "46773dfbe0efadfb7a658b62ebaec0c5d75d087f" and "7e485968143629a6b308c282ae79feedf8375e86" have entirely different histories.

8 changed files with 103 additions and 52 deletions

5
.gitignore vendored
View File

@ -1,5 +1,8 @@
# OS
.DS_Store
# IDEs # IDEs
.idea/ .idea/
# Ignore private configurations # Ignore private configurations
private/ssh-config ssh-config.nix

40
Brewfile Normal file
View File

@ -0,0 +1,40 @@
tap "homebrew/bundle"
brew "webp"
brew "awscli"
brew "libpq"
brew "ncdu"
brew "nvm"
brew "tree"
cask "1password"
cask "alfred"
cask "divvy"
cask "docker"
cask "google-chrome"
cask "google-drive"
cask "hiddenbar"
cask "kap"
cask "obs"
cask "slack"
cask "steam"
cask "telegram"
cask "transmission"
cask "visual-studio-code"
cask "vlc"
cask "warp"
cask "webstorm"
cask "whatsapp"
vscode "Angular.ng-template"
vscode "bradlc.vscode-tailwindcss"
vscode "cweijan.vscode-mysql-client2"
vscode "esbenp.prettier-vscode"
vscode "GitHub.copilot"
vscode "mikestead.dotenv"
vscode "ms-vscode.cpptools"
vscode "nrwl.angular-console"
vscode "platformio.platformio-ide"
vscode "Postman.postman-for-vscode"
vscode "Prisma.prisma"
vscode "svelte.svelte-vscode"
vscode "syler.sass-indented"
vscode "vscode-icons-team.vscode-icons"
vscode "xaver.clang-format"

View File

@ -1,21 +1,22 @@
# Dotfiles # Dotfiles
In this repo I store my config files. In this repo I store my config files.
It helps me to install quickly all software I need for work and fun. - `Brewfile` for macOS (I'm about to drop it).
Feel free to check & alter the configs as you like. - `configuration.nix` for NixOS (a new linux distro for me, that I'm exploring as a replacement for macOS).
It helps me to install quickly all software I need for work and fun.
Feel free to check & alter the list of software to be installed in these files.
I use NixOS. It stores all of its configuration in `configuration.nix`. ## Installation
Start your exploration there.
If you are confused at any step - checkout docs on https://nixos.org/
## Install ### macOS/Brew
1. Install Brew from here: https://brew.sh/
2. Copy Brewfile to your computer and run `brew bundle` from the same folder where you copied the file.
3. Run `chmod +x ./cron-adjust-microphone-gain-to-100.sh` and `./cron-adjust-microphone-gain-to-100.sh` [to change microphone gain to 100% on macOS](https://apple.stackexchange.com/questions/97810/mac-osx-microphone-input-volume-level-auto-adjusts-can-it-be-disabled).
1. Clone this repo. Note: Brew will ask you for the root password and other apps inside Brewfile might ask you for your password as well.
2. Give build script permission to execute: `chmod +x ./build-nix.sh`. Usually installation takes 10-20 min, so make sure to brew a cup of tea or coffee :)
3. [Optionally] Check example files in `./private` folder. If anything there you'd like to use - copy example file and remove ".example" suffix. Fill file with your content. Example: SSH Config `cp ./private/ssh-config.nix.example ./private/ssh-config.nix` and fill with your values.
4. Apply configuration with `make`.
## Usage ### NixOS
1. `chmod +x ./build-nix.sh`
1. Change configuration files to desired state. 2. [Optionally] SSH Config `cp ./ssh-config.nix.example ./ssh-config.nix` and fill with your values.
2. Apply configuration with `make`. 3. [First run] `./build-nix.sh` or [then] just `make`

View File

@ -10,11 +10,13 @@ echo "Checking for sudo access..."
# Ensure the script is being run with superuser privileges # Ensure the script is being run with superuser privileges
sudo -v sudo -v
echo "Backing up current configuration..."
# Create a backup of the current configuration file with a timestamp
sudo cp "${NIXOS_CONFIG_PATH}/configuration.nix" "${NIXOS_CONFIG_PATH}/configuration.nix-backup-$(date +%F-%H-%M-%S)"
echo "Copying new configuration..." echo "Copying new configuration..."
# Copy the local configuration.nix to the system configuration location # Copy the local configuration.nix to the system configuration location
sudo cp ./configuration.nix "${NIXOS_CONFIG_PATH}" sudo cp ./*.nix "${NIXOS_CONFIG_PATH}"
sudo mkdir -p "${NIXOS_CONFIG_PATH}/private"
sudo cp ./private/* "${NIXOS_CONFIG_PATH}/private/"
echo "Rebuilding NixOS configuration..." echo "Rebuilding NixOS configuration..."
# Rebuild the NixOS configuration and make the changes effective # Rebuild the NixOS configuration and make the changes effective

View File

@ -5,29 +5,23 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
nixFolder = "/etc/nixos"; sshConfigPath = ./ssh-config.nix;
username = "spy4x"; gdrivePath = "/home/spy4x/gdrive";
userFullName = "Anton Shubin";
sshConfigPath = "${nixFolder}/private/ssh-config";
sshConfig = if builtins.pathExists "${sshConfigPath}" then builtins.readFile "${sshConfigPath}" else "# private ssh config file didn't exist to insert it's content here";
gdrivePath = "/home/${username}/gdrive";
curBin = "/run/current-system/sw/bin"; curBin = "/run/current-system/sw/bin";
home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/release-23.11.tar.gz";
in in
{ {
imports = imports =
[ [
# Include the results of the hardware scan. # Include the results of the hardware scan.
./hardware-configuration.nix ./hardware-configuration.nix
(import "${home-manager}/nixos") ] ++ lib.optional (builtins.pathExists sshConfigPath) sshConfigPath;
];
# Bootloader. # Bootloader.
boot.loader.grub.enable = true; boot.loader.grub.enable = true;
boot.loader.grub.device = "/dev/nvme0n1"; boot.loader.grub.device = "/dev/nvme0n1";
boot.loader.grub.useOSProber = true; boot.loader.grub.useOSProber = true;
networking.hostName = "${username}-pc"; networking.hostName = "spy4x-pc";
networking.networkmanager.enable = true; networking.networkmanager.enable = true;
networking = { networking = {
firewall = { firewall = {
@ -98,24 +92,10 @@ in
hardware.logitech.wireless.enable = true; hardware.logitech.wireless.enable = true;
hardware.logitech.wireless.enableGraphical = true; hardware.logitech.wireless.enableGraphical = true;
home-manager.users.spy4x = {
home.stateVersion = "23.11";
home.username = username;
home.homeDirectory = "/home/${username}";
home.packages = with pkgs; [
wget
];
programs.ssh.enable = true;
programs.ssh.extraConfig = ''
${sshConfig}
'';
};
# Define a user account. Don't forget to set a password with passwd. # Define a user account. Don't forget to set a password with passwd.
users.users.spy4x = { users.users.spy4x = {
isNormalUser = true; isNormalUser = true;
description = userFullName; description = "Anton Shubin";
extraGroups = [ extraGroups = [
"networkmanager" "networkmanager"
"wheel" "wheel"
@ -159,13 +139,14 @@ in
# Shell aliases and other init # Shell aliases and other init
environment.interactiveShellInit = '' environment.interactiveShellInit = ''
alias copy='wl-copy <' alias copy='wl-copy <'
alias build='sudo nixos-rebuild switch'
alias rs='rsync -avhzru -P' alias rs='rsync -avhzru -P'
alias rsh='rsync -avhzru -P -e ssh' alias rsh='rsync -avhzru -P -e ssh'
''; '';
# Enable automatic login for the user. # Enable automatic login for the user.
services.xserver.displayManager.autoLogin.enable = true; services.xserver.displayManager.autoLogin.enable = true;
services.xserver.displayManager.autoLogin.user = username; services.xserver.displayManager.autoLogin.user = "spy4x";
# RClone Google Drive service # RClone Google Drive service
systemd.services.rclone-gdrive-mount = { systemd.services.rclone-gdrive-mount = {
@ -182,7 +163,7 @@ in
ExecStop = "${curBin}/fusermount -u ${gdrivePath}"; ExecStop = "${curBin}/fusermount -u ${gdrivePath}";
Restart = "on-failure"; Restart = "on-failure";
RestartSec = "10s"; RestartSec = "10s";
User = username; User = "spy4x";
Group = "users"; Group = "users";
Environment = [ "PATH=/run/wrappers/bin/:$PATH" ]; # Required environments Environment = [ "PATH=/run/wrappers/bin/:$PATH" ]; # Required environments
}; };

View File

@ -0,0 +1,19 @@
#!/bin/sh
# If the microphone gain is less than 100, increase it by 3 every 0.1 seconds until it reaches 100
CRON_JOB="* * * * * while (( \$(osascript -e \"input volume of (get volume settings)\") < 100 )); do osascript -e \"set volume input volume (input volume of (get volume settings) + 3)\"; sleep 0.1; done;"
# Escape percent signs for cron
ESCAPED_CRON_JOB=$(echo "${CRON_JOB}" | sed 's/%/\\%/g')
# Backup current crontab (just in case)
CRONTAB_BACKUP=$(crontab -l)
# Check if the cron job already exists
if echo "${CRONTAB_BACKUP}" | grep -F -- "${CRON_JOB}" > /dev/null 2>&1; then
echo "Cron job already exists. Not adding again."
else
# Add the cron job to the crontab
(echo "${CRONTAB_BACKUP}"; echo "${ESCAPED_CRON_JOB}") | crontab -
echo "Cron job added."
fi

View File

@ -1,7 +0,0 @@
# Part of config, to remote machine aliases for SSH
Host my-remote-machine # alias to do "ssh my remote-machine"
HostName 192.192.192.192 # ip/hostname
User my-user # username
# ... other hosts

12
ssh-config.nix.example Normal file
View File

@ -0,0 +1,12 @@
# Part of config, to remote machine aliases for SSH
{ ... }: {
programs.ssh.extraConfig = ''
Host my-remote-machine # alias to do "ssh my remote-machine"
HostName 192.192.192.192 # ip/hostname
User my-user # username
# ... other hosts
'';
}