From 346861e2fcb5bce19a1e4249b2bef99be49feb77 Mon Sep 17 00:00:00 2001 From: Munam Mubashir <38868658+aightmunam@users.noreply.github.com> Date: Thu, 9 Oct 2025 21:46:53 +0200 Subject: [PATCH 1/4] Create .pre-commit-config.yaml Add pre-commit configuration with hooks for YAML, TOML, shell scripts, and Lua files. This includes syntax checking, linting, and formatting hooks. --- .pre-commit-config.yaml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..3890de5 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,29 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-yaml + name: Check YAML syntax + - id: check-toml + name: Check TOML syntax + - id: end-of-file-fixer + - id: trailing-whitespace + - id: mixed-line-ending + - repo: https://github.com/jumanjihouse/pre-commit-hooks + rev: 3.0.0 + hooks: + - id: shellcheck + name: Check shell scripts with shellcheck + args: ['--severity=warning'] + - repo: https://github.com/koalaman/shellcheck-precommit + rev: v0.9.0.6 + hooks: + - id: shellcheck + name: Shellcheck for sh files + types: [shell] + - repo: https://github.com/Vimjas/vint + rev: v0.3.21 + hooks: + - id: vint + name: Lint Lua files + files: \.lua$ From 9cc1bca13d9a5be5d028e8dea10856e4cbcea6d5 Mon Sep 17 00:00:00 2001 From: Munam Mubashir <38868658+aightmunam@users.noreply.github.com> Date: Thu, 9 Oct 2025 21:47:58 +0200 Subject: [PATCH 2/4] Update dotfiles-ci.yml Add pre-commit job to GitHub Actions workflow. This job installs Python, sets up pre-commit, and runs all configured hooks. Updated validation job to depend on all checks including pre-commit. --- .github/workflows/dotfiles-ci.yml | 45 ++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/.github/workflows/dotfiles-ci.yml b/.github/workflows/dotfiles-ci.yml index 970041e..4cb6ead 100644 --- a/.github/workflows/dotfiles-ci.yml +++ b/.github/workflows/dotfiles-ci.yml @@ -26,6 +26,26 @@ jobs: sudo apt-get install -y yamllint find . -name '*.yml' -o -name '*.yaml' | xargs yamllint || true + pre-commit: + name: Pre-commit Checks + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install pre-commit + run: | + python -m pip install --upgrade pip + pip install pre-commit + + - name: Run pre-commit hooks + run: pre-commit run --all-files + nix-build: name: Nix Build runs-on: ubuntu-latest @@ -39,15 +59,10 @@ jobs: nix_path: nixpkgs=channel:nixos-unstable - name: Build Nix configuration - run: | - if [ -f "flake.nix" ]; then - nix build .#homeConfigurations.$(whoami).activationPackage --show-trace || echo "Nix build attempted" - else - echo "No flake.nix found, skipping Nix build" - fi + run: nix-build '' -A hello || true home-manager-check: - name: Home Manager Configuration Check + name: Home Manager Check runs-on: ubuntu-latest steps: - name: Checkout repository @@ -58,20 +73,20 @@ jobs: with: nix_path: nixpkgs=channel:nixos-unstable + - name: Install Home Manager + run: | + nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager + nix-channel --update + - name: Check Home Manager configuration run: | - if [ -f "home.nix" ] || [ -f "flake.nix" ]; then - nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager - nix-channel --update - echo "Home Manager configuration found" - else - echo "No Home Manager configuration found, skipping" - fi + export NIX_PATH=$HOME/.nix-defexpr/channels:/nix/var/nix/profiles/per-user/root/channels${NIX_PATH:+:$NIX_PATH} + echo "Home Manager check would run here" validation: name: Validation Summary runs-on: ubuntu-latest - needs: [lint, nix-build, home-manager-check] + needs: [lint, pre-commit, nix-build, home-manager-check] steps: - name: All checks passed run: echo "All validation checks completed successfully!" From a45edcb882ff80363deac641953f17648ee8da4b Mon Sep 17 00:00:00 2001 From: Munam Mubashir <38868658+aightmunam@users.noreply.github.com> Date: Thu, 9 Oct 2025 22:05:36 +0200 Subject: [PATCH 3/4] Fix pre-commit-config Add something for linting --- .dircolors | 2 +- .pre-commit-config.yaml | 23 ++--------------------- .zshrc | 2 +- Makefile | 1 - README.md | 9 ++++----- git/.gitconfig | 3 +-- git/.gitignore_global | 1 - home-manager/flake.nix | 2 +- nvim/.stylua.toml | 1 - tmux/.tmux.conf | 1 - vim/autoload/.gitignore | 2 +- vim/colors/silverwind.vim | 2 +- vim/plugged/.gitignore | 2 +- 13 files changed, 13 insertions(+), 38 deletions(-) diff --git a/.dircolors b/.dircolors index 3d3c56f..65b7cec 100644 --- a/.dircolors +++ b/.dircolors @@ -544,4 +544,4 @@ TERM xterm-256color TERM xterm-88color TERM xterm-color TERM xterm-debian -TERM xterm-kitty \ No newline at end of file +TERM xterm-kitty diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3890de5..f43e66e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,29 +1,10 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v6.0.0 hooks: - id: check-yaml - name: Check YAML syntax - id: check-toml - name: Check TOML syntax - id: end-of-file-fixer + - id: check-json - id: trailing-whitespace - id: mixed-line-ending - - repo: https://github.com/jumanjihouse/pre-commit-hooks - rev: 3.0.0 - hooks: - - id: shellcheck - name: Check shell scripts with shellcheck - args: ['--severity=warning'] - - repo: https://github.com/koalaman/shellcheck-precommit - rev: v0.9.0.6 - hooks: - - id: shellcheck - name: Shellcheck for sh files - types: [shell] - - repo: https://github.com/Vimjas/vint - rev: v0.3.21 - hooks: - - id: vint - name: Lint Lua files - files: \.lua$ diff --git a/.zshrc b/.zshrc index 0b62fd3..82fbcc7 100644 --- a/.zshrc +++ b/.zshrc @@ -107,7 +107,7 @@ for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do done ####################################################### -# Nix +# Nix ####################################################### export NIX_CONF_DIR=$HOME/.config/nix diff --git a/Makefile b/Makefile index 2da5c6a..79d84bc 100644 --- a/Makefile +++ b/Makefile @@ -23,4 +23,3 @@ build: exit 1; \ } NIXPKGS_ALLOW_UNFREE=1 nix run home-manager -- switch --flake ./home-manager#mynixos --impure -b backup - diff --git a/README.md b/README.md index 370925c..207ac97 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,18 @@ dotfiles -My Dotfiles for git, vim/nvim, zsh and more. +My Dotfiles for git, vim/nvim, zsh and more. ### Steps to setup these dotfiles on your machine 1. Clone this repo in $HOME/dotfiles (~/dotfiles) directory ``` # if SSH has been added for the machine - git clone git@github.com:aightmunam/dotfiles.git - + git clone git@github.com:aightmunam/dotfiles.git + git clone https://github.com/aightmunam/dotfiles.git ``` #### Using Nix home-manager: 2. Navigate into dotfiles/nix directory ``` make setup -make build +make build ``` - diff --git a/git/.gitconfig b/git/.gitconfig index 1aab206..dc20293 100644 --- a/git/.gitconfig +++ b/git/.gitconfig @@ -2,7 +2,7 @@ path = ~/.gitconfig.local [user] name = Munam Mubashir - email = 38868658+aightmunam@users.noreply.github.com + email = 38868658+aightmunam@users.noreply.github.com [status] relativePaths = true [pull] @@ -70,4 +70,3 @@ current = yellow reverse local = yellow remote = green - diff --git a/git/.gitignore_global b/git/.gitignore_global index 8a6369f..5e0f4ad 100644 --- a/git/.gitignore_global +++ b/git/.gitignore_global @@ -36,4 +36,3 @@ pyrightconfig.json # zed ide specific (allows adding venv/python path) Icon? ehthumbs.db Thumbs.db - diff --git a/home-manager/flake.nix b/home-manager/flake.nix index b93c2f8..7852e34 100644 --- a/home-manager/flake.nix +++ b/home-manager/flake.nix @@ -9,7 +9,7 @@ }; outputs = inputs: let - username = builtins.getEnv "USER"; + username = builtins.getEnv "USER"; flakeContext = { inherit inputs username; }; diff --git a/nvim/.stylua.toml b/nvim/.stylua.toml index 9796293..533dda7 100644 --- a/nvim/.stylua.toml +++ b/nvim/.stylua.toml @@ -4,4 +4,3 @@ indent_type = "Spaces" indent_width = 2 quote_style = "ForceSingle" call_parentheses = "None" - diff --git a/tmux/.tmux.conf b/tmux/.tmux.conf index 44cc3c6..9b75344 100644 --- a/tmux/.tmux.conf +++ b/tmux/.tmux.conf @@ -92,4 +92,3 @@ set -g @plugin 'christoomey/vim-tmux-navigator' set -g @plugin 'vaaleyard/tmux-dotbar' set -g @tmux-dotbar-position bottom run '~/.tmux/plugins/tpm/tpm' - diff --git a/vim/autoload/.gitignore b/vim/autoload/.gitignore index 5e9d0c4..0d675bb 100644 --- a/vim/autoload/.gitignore +++ b/vim/autoload/.gitignore @@ -2,4 +2,4 @@ * # except this file -!.gitignore \ No newline at end of file +!.gitignore diff --git a/vim/colors/silverwind.vim b/vim/colors/silverwind.vim index 6cf8dd6..e6d002f 100644 --- a/vim/colors/silverwind.vim +++ b/vim/colors/silverwind.vim @@ -55,4 +55,4 @@ highlight mailEmail ctermfg=107 cterm=underline highlight SpellBad ctermfg=160 ctermbg=NONE cterm=underline highlight SpellRare ctermfg=168 ctermbg=NONE cterm=underline highlight SpellCap ctermfg=189 ctermbg=NONE cterm=underline -highlight MatchParen ctermfg=15 ctermbg=23 \ No newline at end of file +highlight MatchParen ctermfg=15 ctermbg=23 diff --git a/vim/plugged/.gitignore b/vim/plugged/.gitignore index 5e9d0c4..0d675bb 100644 --- a/vim/plugged/.gitignore +++ b/vim/plugged/.gitignore @@ -2,4 +2,4 @@ * # except this file -!.gitignore \ No newline at end of file +!.gitignore From fcca5e21ad0176c846e838d08269673612380954 Mon Sep 17 00:00:00 2001 From: Munam Mubashir <38868658+aightmunam@users.noreply.github.com> Date: Thu, 9 Oct 2025 22:12:18 +0200 Subject: [PATCH 4/4] Update workflow --- .github/workflows/dotfiles-ci.yml | 72 +++++++++++-------------------- 1 file changed, 26 insertions(+), 46 deletions(-) diff --git a/.github/workflows/dotfiles-ci.yml b/.github/workflows/dotfiles-ci.yml index 4cb6ead..96c3a18 100644 --- a/.github/workflows/dotfiles-ci.yml +++ b/.github/workflows/dotfiles-ci.yml @@ -1,4 +1,4 @@ -name: Dotfiles CI +name: CI on: push: @@ -8,24 +8,6 @@ on: workflow_dispatch: jobs: - lint: - name: Lint Dotfiles - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Lint shell scripts - run: | - sudo apt-get update - sudo apt-get install -y shellcheck - find . -name '*.sh' -type f -print0 | xargs -0 shellcheck || true - - - name: Check YAML syntax - run: | - sudo apt-get install -y yamllint - find . -name '*.yml' -o -name '*.yaml' | xargs yamllint || true - pre-commit: name: Pre-commit Checks runs-on: ubuntu-latest @@ -46,47 +28,45 @@ jobs: - name: Run pre-commit hooks run: pre-commit run --all-files - nix-build: - name: Nix Build - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Install Nix - uses: cachix/install-nix-action@v26 - with: - nix_path: nixpkgs=channel:nixos-unstable - - - name: Build Nix configuration - run: nix-build '' -A hello || true - - home-manager-check: - name: Home Manager Check + setup-and-build: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install Nix - uses: cachix/install-nix-action@v26 + uses: cachix/install-nix-action@v25 with: - nix_path: nixpkgs=channel:nixos-unstable + extra_nix_config: | + experimental-features = nix-command flakes - - name: Install Home Manager + - name: Build and apply Home Manager config + env: + NIXPKGS_ALLOW_UNFREE: "1" run: | - nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager - nix-channel --update - - - name: Check Home Manager configuration + echo "Checking Nix installation and flake support" + nix --version + grep -qxF 'experimental-features = nix-command flakes' ~/.config/nix/nix.conf || \ + echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf + echo "Running flake build (home-manager switch)" + nix run home-manager -- switch --flake ./home-manager#mynixos --impure -b backup + + - name: Validate dotfile presence run: | - export NIX_PATH=$HOME/.nix-defexpr/channels:/nix/var/nix/profiles/per-user/root/channels${NIX_PATH:+:$NIX_PATH} - echo "Home Manager check would run here" + test -f ~/.config/nvim/init.lua || echo "Missing Neovim config" + test -f ~/.config/aerospace/aerospace.toml || echo "Missing aerospace config" + test -f ~/.config/wezterm/config.lua || echo "Missing Wezterm config" + test -f ~/.zshrc || echo "Missing Zsh config" + test -f ~/.gitconfig || echo "Missing Git config" + test -f ~/.tmux.conf || echo "Missing Tmux config" + + - name: Show Home Manager generations + run: home-manager generations || true validation: name: Validation Summary runs-on: ubuntu-latest - needs: [lint, pre-commit, nix-build, home-manager-check] + needs: [pre-commit, setup-and-build] steps: - name: All checks passed run: echo "All validation checks completed successfully!"