Compare commits
No commits in common. "42ad6bf710dc1dfb553ac99bc7f6f0b6a7448f75" and "7e485968143629a6b308c282ae79feedf8375e86" have entirely different histories.
42ad6bf710
...
7e48596814
18
.editorconfig
Normal file
18
.editorconfig
Normal file
@ -0,0 +1,18 @@
|
||||
# EditorConfig is awesome: https://editorconfig.org
|
||||
|
||||
# top-most .editorconfig file
|
||||
root = true
|
||||
|
||||
# All files
|
||||
[*]
|
||||
indent_style = space # Use spaces for indentation
|
||||
indent_size = 2 # Number of spaces used per indentation level
|
||||
|
||||
|
||||
# Override for Makefile
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
|
||||
# Markdown files (md)
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false # Markdown can use trailing whitespace for line breaks
|
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# OS
|
||||
.DS_Store
|
||||
|
||||
# IDEs
|
||||
.idea/
|
||||
|
||||
# Ignore private configurations
|
||||
ssh-config.nix
|
40
Brewfile
Normal file
40
Brewfile
Normal 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"
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 spy4x
|
||||
Copyright (c) 2024 Anton Shubin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
7
Makefile
Normal file
7
Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
# Makefile for updating NixOS configuration
|
||||
|
||||
.PHONY: all
|
||||
|
||||
# Default target
|
||||
all:
|
||||
./build-nix.sh
|
23
README.md
23
README.md
@ -1,3 +1,22 @@
|
||||
# dotfiles
|
||||
# Dotfiles
|
||||
|
||||
Configs that help me to quickly install all software I need for work and fun, and configure OS.
|
||||
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.
|
||||
Feel free to check & alter the list of software to be installed in these files.
|
||||
|
||||
## Installation
|
||||
|
||||
### 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).
|
||||
|
||||
Note: Brew will ask you for the root password and other apps inside Brewfile might ask you for your password as well.
|
||||
Usually installation takes 10-20 min, so make sure to brew a cup of tea or coffee :)
|
||||
|
||||
### NixOS
|
||||
1. `chmod +x ./build-nix.sh`
|
||||
2. [Optionally] SSH Config `cp ./ssh-config.nix.example ./ssh-config.nix` and fill with your values.
|
||||
3. [First run] `./build-nix.sh` or [then] just `make`
|
25
build-nix.sh
Executable file
25
build-nix.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Make sure that the script exits if any command returns a non-zero exit code
|
||||
set -e
|
||||
|
||||
# Define the path to the system configuration file
|
||||
NIXOS_CONFIG_PATH="/etc/nixos"
|
||||
|
||||
echo "Checking for sudo access..."
|
||||
# Ensure the script is being run with superuser privileges
|
||||
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..."
|
||||
# Copy the local configuration.nix to the system configuration location
|
||||
sudo cp ./*.nix "${NIXOS_CONFIG_PATH}"
|
||||
|
||||
echo "Rebuilding NixOS configuration..."
|
||||
# Rebuild the NixOS configuration and make the changes effective
|
||||
sudo nixos-rebuild switch
|
||||
|
||||
echo "NixOS configuration updated successfully."
|
177
configuration.nix
Normal file
177
configuration.nix
Normal file
@ -0,0 +1,177 @@
|
||||
# Edit this configuration file to define what should be installed on
|
||||
# your system. Help is available in the configuration.nix(5) man page
|
||||
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
||||
|
||||
{ config, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
sshConfigPath = ./ssh-config.nix;
|
||||
gdrivePath = "/home/spy4x/gdrive";
|
||||
curBin = "/run/current-system/sw/bin";
|
||||
in
|
||||
{
|
||||
imports =
|
||||
[
|
||||
# Include the results of the hardware scan.
|
||||
./hardware-configuration.nix
|
||||
] ++ lib.optional (builtins.pathExists sshConfigPath) sshConfigPath;
|
||||
|
||||
# Bootloader.
|
||||
boot.loader.grub.enable = true;
|
||||
boot.loader.grub.device = "/dev/nvme0n1";
|
||||
boot.loader.grub.useOSProber = true;
|
||||
|
||||
networking.hostName = "spy4x-pc";
|
||||
networking.networkmanager.enable = true;
|
||||
networking = {
|
||||
firewall = {
|
||||
enable = true;
|
||||
allowedTCPPorts = [
|
||||
# BEGIN Web server to debug apps from mobile
|
||||
80
|
||||
4200
|
||||
4201
|
||||
5173
|
||||
5174
|
||||
8080
|
||||
8081
|
||||
# END Web server to debug apps from mobile
|
||||
53317 # LocalSend
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
# Allow install "unfree" apps, like Google Chrome or WebStorm
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
|
||||
time.timeZone = "Asia/Singapore";
|
||||
|
||||
i18n.defaultLocale = "en_SG.UTF-8";
|
||||
i18n.extraLocaleSettings = {
|
||||
LC_ADDRESS = "en_SG.UTF-8";
|
||||
LC_IDENTIFICATION = "en_SG.UTF-8";
|
||||
LC_MEASUREMENT = "en_SG.UTF-8";
|
||||
LC_MONETARY = "en_SG.UTF-8";
|
||||
LC_NAME = "en_SG.UTF-8";
|
||||
LC_NUMERIC = "en_SG.UTF-8";
|
||||
LC_PAPER = "en_SG.UTF-8";
|
||||
LC_TELEPHONE = "en_SG.UTF-8";
|
||||
LC_TIME = "en_SG.UTF-8";
|
||||
};
|
||||
|
||||
# Enable the X11 windowing system.
|
||||
services.xserver.enable = true;
|
||||
|
||||
# Enable the GNOME Desktop Environment.
|
||||
services.xserver.displayManager.gdm.enable = true;
|
||||
services.xserver.desktopManager.gnome.enable = true;
|
||||
|
||||
# Configure keymap in X11
|
||||
services.xserver = {
|
||||
layout = "us";
|
||||
xkbVariant = "";
|
||||
};
|
||||
|
||||
# Activate and configure Docker
|
||||
virtualisation.docker.enable = true;
|
||||
virtualisation.docker.autoPrune.enable = true;
|
||||
# virtualisation.docker.enableNvidia = true; # experiment for Roley?
|
||||
|
||||
# Enable sound with pipewire.
|
||||
sound.enable = true;
|
||||
hardware.pulseaudio.enable = false;
|
||||
security.rtkit.enable = true;
|
||||
services.pipewire = {
|
||||
enable = true;
|
||||
alsa.enable = true;
|
||||
alsa.support32Bit = true;
|
||||
pulse.enable = true;
|
||||
};
|
||||
|
||||
# Logitech devices manager "Solaar". Gives necessary permissions to run it without "sudo.
|
||||
hardware.logitech.wireless.enable = true;
|
||||
hardware.logitech.wireless.enableGraphical = true;
|
||||
|
||||
# Define a user account. Don't forget to set a password with ‘passwd’.
|
||||
users.users.spy4x = {
|
||||
isNormalUser = true;
|
||||
description = "Anton Shubin";
|
||||
extraGroups = [
|
||||
"networkmanager"
|
||||
"wheel"
|
||||
"bluetooth"
|
||||
"docker"
|
||||
];
|
||||
packages = with pkgs; [
|
||||
# Shell tools
|
||||
git
|
||||
gnumake # Source for "make" command
|
||||
htop # System monitor viewer
|
||||
unzip
|
||||
killall # Kill processes by name instead of PID
|
||||
ncdu # Disk space usage stats, per folder, nested
|
||||
libwebp # Convert images into .webp format
|
||||
wl-clipboard # Wayland's clipboard copy/paste cli tools
|
||||
tree
|
||||
nixpkgs-fmt # Formatter for .nix files. Like Prettier.
|
||||
|
||||
# Work
|
||||
nodejs_21
|
||||
nodePackages.pnpm
|
||||
vscode-fhs # Wrapped variant of vscode which launches in a FHS compatible environment. Should allow for easy usage of extensions without nix-specific modifications.
|
||||
jetbrains.webstorm
|
||||
upwork
|
||||
slack
|
||||
ffmpeg # for Roley project
|
||||
awscli
|
||||
|
||||
# Other
|
||||
google-chrome
|
||||
bitwarden # Password manager client
|
||||
vlc
|
||||
obs-studio # Video recorder and stream software
|
||||
localsend # Share files/text/data with other devices in local network without internet. OSS alternative to AirDrop.
|
||||
rclone # Sync Google Drive with a local folder
|
||||
];
|
||||
};
|
||||
programs.steam.enable = true; # Install Steam for games management
|
||||
|
||||
# Shell aliases and other init
|
||||
environment.interactiveShellInit = ''
|
||||
alias copy='wl-copy <'
|
||||
alias build='sudo nixos-rebuild switch'
|
||||
alias rs='rsync -avhzru -P'
|
||||
alias rsh='rsync -avhzru -P -e ssh'
|
||||
'';
|
||||
|
||||
# Enable automatic login for the user.
|
||||
services.xserver.displayManager.autoLogin.enable = true;
|
||||
services.xserver.displayManager.autoLogin.user = "spy4x";
|
||||
|
||||
# RClone Google Drive service
|
||||
systemd.services.rclone-gdrive-mount = {
|
||||
# Ensure the service starts after the network is up
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
requires = [ "network-online.target" ];
|
||||
|
||||
# Service configuration
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
ExecStartPre = "${curBin}/mkdir -p ${gdrivePath}";
|
||||
ExecStart = "${pkgs.rclone}/bin/rclone mount gdrive: ${gdrivePath} --vfs-cache-mode full --vfs-cache-max-age 72h --vfs-cache-max-size 100G --vfs-read-ahead 2G";
|
||||
ExecStop = "${curBin}/fusermount -u ${gdrivePath}";
|
||||
Restart = "on-failure";
|
||||
RestartSec = "10s";
|
||||
User = "spy4x";
|
||||
Group = "users";
|
||||
Environment = [ "PATH=/run/wrappers/bin/:$PATH" ]; # Required environments
|
||||
};
|
||||
};
|
||||
|
||||
# Workaround for GNOME autologin: https://github.com/NixOS/nixpkgs/issues/103746#issuecomment-945091229
|
||||
systemd.services."getty@tty1".enable = false;
|
||||
systemd.services."autovt@tty1".enable = false;
|
||||
|
||||
system.stateVersion = "23.11";
|
||||
}
|
19
cron-adjust-microphone-gain-to-100.sh
Executable file
19
cron-adjust-microphone-gain-to-100.sh
Executable 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
|
12
ssh-config.nix.example
Normal file
12
ssh-config.nix.example
Normal 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
|
||||
'';
|
||||
}
|
Loading…
Reference in New Issue
Block a user