Compare commits
2 Commits
7e48596814
...
46773dfbe0
Author | SHA1 | Date | |
---|---|---|---|
46773dfbe0 | |||
bd7556a682 |
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,8 +1,5 @@
|
|||||||
# OS
|
|
||||||
.DS_Store
|
|
||||||
|
|
||||||
# IDEs
|
# IDEs
|
||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
# Ignore private configurations
|
# Ignore private configurations
|
||||||
ssh-config.nix
|
private/ssh-config
|
40
Brewfile
40
Brewfile
@ -1,40 +0,0 @@
|
|||||||
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"
|
|
27
README.md
27
README.md
@ -1,22 +1,21 @@
|
|||||||
# Dotfiles
|
# Dotfiles
|
||||||
|
|
||||||
In this repo I store my config files.
|
In this repo I store my config files.
|
||||||
- `Brewfile` for macOS (I'm about to drop it).
|
|
||||||
- `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.
|
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.
|
Feel free to check & alter the configs as you like.
|
||||||
|
|
||||||
## Installation
|
I use NixOS. It stores all of its configuration in `configuration.nix`.
|
||||||
|
Start your exploration there.
|
||||||
|
If you are confused at any step - checkout docs on https://nixos.org/
|
||||||
|
|
||||||
### macOS/Brew
|
## Install
|
||||||
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).
|
|
||||||
|
|
||||||
Note: Brew will ask you for the root password and other apps inside Brewfile might ask you for your password as well.
|
1. Clone this repo.
|
||||||
Usually installation takes 10-20 min, so make sure to brew a cup of tea or coffee :)
|
2. Give build script permission to execute: `chmod +x ./build-nix.sh`.
|
||||||
|
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`.
|
||||||
|
|
||||||
### NixOS
|
## Usage
|
||||||
1. `chmod +x ./build-nix.sh`
|
|
||||||
2. [Optionally] SSH Config `cp ./ssh-config.nix.example ./ssh-config.nix` and fill with your values.
|
1. Change configuration files to desired state.
|
||||||
3. [First run] `./build-nix.sh` or [then] just `make`
|
2. Apply configuration with `make`.
|
@ -10,13 +10,11 @@ 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 ./*.nix "${NIXOS_CONFIG_PATH}"
|
sudo cp ./configuration.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
|
||||||
|
@ -5,23 +5,29 @@
|
|||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
sshConfigPath = ./ssh-config.nix;
|
nixFolder = "/etc/nixos";
|
||||||
gdrivePath = "/home/spy4x/gdrive";
|
username = "spy4x";
|
||||||
|
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
|
||||||
] ++ lib.optional (builtins.pathExists sshConfigPath) sshConfigPath;
|
(import "${home-manager}/nixos")
|
||||||
|
];
|
||||||
|
|
||||||
# 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 = "spy4x-pc";
|
networking.hostName = "${username}-pc";
|
||||||
networking.networkmanager.enable = true;
|
networking.networkmanager.enable = true;
|
||||||
networking = {
|
networking = {
|
||||||
firewall = {
|
firewall = {
|
||||||
@ -92,10 +98,24 @@ 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 = "Anton Shubin";
|
description = userFullName;
|
||||||
extraGroups = [
|
extraGroups = [
|
||||||
"networkmanager"
|
"networkmanager"
|
||||||
"wheel"
|
"wheel"
|
||||||
@ -139,14 +159,13 @@ 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 = "spy4x";
|
services.xserver.displayManager.autoLogin.user = username;
|
||||||
|
|
||||||
# RClone Google Drive service
|
# RClone Google Drive service
|
||||||
systemd.services.rclone-gdrive-mount = {
|
systemd.services.rclone-gdrive-mount = {
|
||||||
@ -163,7 +182,7 @@ in
|
|||||||
ExecStop = "${curBin}/fusermount -u ${gdrivePath}";
|
ExecStop = "${curBin}/fusermount -u ${gdrivePath}";
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
RestartSec = "10s";
|
RestartSec = "10s";
|
||||||
User = "spy4x";
|
User = username;
|
||||||
Group = "users";
|
Group = "users";
|
||||||
Environment = [ "PATH=/run/wrappers/bin/:$PATH" ]; # Required environments
|
Environment = [ "PATH=/run/wrappers/bin/:$PATH" ]; # Required environments
|
||||||
};
|
};
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
#!/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
|
|
7
private/ssh-config.example
Normal file
7
private/ssh-config.example
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# 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
|
@ -1,12 +0,0 @@
|
|||||||
# 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
|
|
||||||
'';
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user