diff options
author | Azat Bahawi <azat@bahawi.net> | 2022-02-16 02:15:52 +0300 |
---|---|---|
committer | Azat Bahawi <azat@bahawi.net> | 2022-02-16 02:15:52 +0300 |
commit | 13964faa53b09924bdd27328311ba27457b0b61d (patch) | |
tree | 73dcca227f3084fd1fa09fd4d3323544b61218ea | |
parent | meh (diff) |
I hate the Antichrist
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | flake.lock | 27 | ||||
-rw-r--r-- | flake.nix | 64 | ||||
-rw-r--r-- | package.yaml | 3 | ||||
-rwxr-xr-x | scripts/nsp-console.sh | 7 | ||||
-rwxr-xr-x | scripts/toggle-compton.sh | 7 | ||||
-rwxr-xr-x | scripts/toggle-redshift.sh | 9 | ||||
-rwxr-xr-x | scripts/toggle-touchpad.sh | 7 | ||||
-rwxr-xr-x | scripts/toggle-trackpoint.sh | 7 | ||||
-rwxr-xr-x | scripts/xmobar/fcitx.sh | 12 | ||||
-rwxr-xr-x | scripts/xshot-select-upload.sh | 6 | ||||
-rwxr-xr-x | scripts/xshot-upload.sh | 6 | ||||
-rw-r--r-- | src/lib/XMonad/Custom/Config.hs | 46 | ||||
-rwxr-xr-x | test.sh | 44 | ||||
-rw-r--r-- | treefmt.toml | 24 |
15 files changed, 178 insertions, 92 deletions
diff --git a/.gitignore b/.gitignore index b384021..39c8a93 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .direnv/ +.pre-commit-config.yaml .stack-work/ cabal.project.local dist-newstyle/ diff --git a/flake.lock b/flake.lock index 51dae57..f0c5f50 100644 --- a/flake.lock +++ b/flake.lock @@ -49,11 +49,36 @@ "type": "github" } }, + "pre-commit-hooks": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1639823344, + "narHash": "sha256-jlsQb2y6A5dB1R0wVPLOfDGM0wLyfYqEJNzMtXuzCXw=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "ff9c0b459ddc4b79c06e19d44251daa8e9cd1746", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "master", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "root": { "inputs": { "flake-compat": "flake-compat", "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" } } }, diff --git a/flake.nix b/flake.nix index 426f9bd..9664dd0 100644 --- a/flake.nix +++ b/flake.nix @@ -24,25 +24,38 @@ ref = "master"; flake = false; }; + + pre-commit-hooks = { + type = "github"; + owner = "cachix"; + repo = "pre-commit-hooks.nix"; + ref = "master"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-utils.follows = "flake-utils"; + }; + }; }; - outputs = { self, nixpkgs, flake-utils, ... }: - flake-utils.lib.eachDefaultSystem (system: + outputs = inputs: + with inputs; + let name = "xmonad-ng"; + in flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; project = returnShellEnv: pkgs.haskellPackages.developPackage { - inherit returnShellEnv; - name = "xmonad-ng"; + inherit name returnShellEnv; root = ./.; overrides = self: _: with pkgs.haskell.lib; - let version = "0.17.0"; + let + mkPackage = packageName: + dontCheck (self.callHackage packageName "0.17.0" { }); in { - xmonad = dontCheck (self.callHackage "xmonad" version { }); - xmonad-contrib = - dontCheck (self.callHackage "xmonad-contrib" version { }); + xmonad = mkPackage "xmonad"; + xmonad-contrib = mkPackage "xmonad-contrib"; }; modifier = drv: pkgs.haskell.lib.addBuildTools drv (with pkgs.haskellPackages; [ @@ -57,8 +70,39 @@ in { defaultPackage = project false; - devShell = project true; + checks.preCommit = pre-commit-hooks.lib.${system}.run { + src = ./.; + hooks = { + nix-linter.enable = true; + nixfmt.enable = true; + hpack.enable = true; + hlint.enable = true; + yamllint.enable = true; + brittany.enable = true; + shellcheck.enable = true; + shfmt = { + enable = true; + name = "shfmt"; + entry = "${pkgs.shfmt}/bin/shfmt -s -w"; + types = [ "shell" ]; + }; + prettier = { + enable = true; + types = [ ]; + files = "\\.((yaml)|\\d)$"; + }; + }; + }; + + shells = { + dev = project true; + commit = pkgs.mkShell { + inherit (self.checks.${system}.preCommit) shellHook; + }; + }; + + devShell = self.shells.${system}.dev; }) // { - overlay = _: _: { xmonad-ng = self.defaultPackage; }; + overlay = _: _: { ${name} = self.defaultPackage; }; }; } diff --git a/package.yaml b/package.yaml index e197d7b..30a47f9 100644 --- a/package.yaml +++ b/package.yaml @@ -40,8 +40,7 @@ executable: - -threaded - -v0 - -with-rtsopts=-N - dependencies: - xmonad-ng + dependencies: xmonad-ng when: - condition: false other-modules: Paths_xmonad_ng diff --git a/scripts/nsp-console.sh b/scripts/nsp-console.sh index 510ecdb..4ac9e32 100755 --- a/scripts/nsp-console.sh +++ b/scripts/nsp-console.sh @@ -1,8 +1,7 @@ #!/bin/sh -if tmux list-sessions | grep "scratchpad" -then - tmux attach-session -t "scratchpad" +if tmux list-sessions | grep "scratchpad"; then + tmux attach-session -t "scratchpad" else - tmux new-session -s "scratchpad" -n "scratchpad" -c "$HOME" + tmux new-session -s "scratchpad" -n "scratchpad" -c "$HOME" fi diff --git a/scripts/toggle-compton.sh b/scripts/toggle-compton.sh index e5a3aaa..0fcb1bf 100755 --- a/scripts/toggle-compton.sh +++ b/scripts/toggle-compton.sh @@ -1,8 +1,7 @@ #!/bin/sh -if ! pgrep compton > /dev/null 2>&1 -then - compton -b +if ! pgrep compton >/dev/null 2>&1; then + compton -b else - pkill compton + pkill compton fi diff --git a/scripts/toggle-redshift.sh b/scripts/toggle-redshift.sh index 2813aea..2af8258 100755 --- a/scripts/toggle-redshift.sh +++ b/scripts/toggle-redshift.sh @@ -1,9 +1,8 @@ #!/usr/bin/env bash -if ! pgrep redshift > /dev/null 2>&1 -then - redshift & - disown redshift +if ! pgrep redshift >/dev/null 2>&1; then + redshift & + disown redshift else - pkill redshift + pkill redshift fi diff --git a/scripts/toggle-touchpad.sh b/scripts/toggle-touchpad.sh index 449bd5b..2a1c061 100755 --- a/scripts/toggle-touchpad.sh +++ b/scripts/toggle-touchpad.sh @@ -3,9 +3,8 @@ ID=$(xinput list | grep -Eo 'TouchPad\s*id\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}') STATE=$(xinput list-props "$ID" | awk '/Device Enabled/ {print $4}') -if [ "$STATE" = 1 ] -then - xinput disable "$ID" +if [ "$STATE" = 1 ]; then + xinput disable "$ID" else - xinput enable "$ID" + xinput enable "$ID" fi diff --git a/scripts/toggle-trackpoint.sh b/scripts/toggle-trackpoint.sh index 1429dcf..d385553 100755 --- a/scripts/toggle-trackpoint.sh +++ b/scripts/toggle-trackpoint.sh @@ -3,9 +3,8 @@ ID=$(xinput list | grep -Eo 'TrackPoint\s*id\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}') STATE=$(xinput list-props "$ID" | awk '/Device Enabled/ {print $4}') -if [ "$STATE" = 1 ] -then - xinput disable "$ID" +if [ "$STATE" = 1 ]; then + xinput disable "$ID" else - xinput enable "$ID" + xinput enable "$ID" fi diff --git a/scripts/xmobar/fcitx.sh b/scripts/xmobar/fcitx.sh index 48eefa0..f159c41 100755 --- a/scripts/xmobar/fcitx.sh +++ b/scripts/xmobar/fcitx.sh @@ -2,14 +2,12 @@ STATUS="$(fcitx-remote)" -if [ "$STATUS" = 0 ] -then - OUT="Off" -elif [ "$STATUS" = 1 ] -then - OUT="Disabled" +if [ "$STATUS" = 0 ]; then + OUT="Off" +elif [ "$STATUS" = 1 ]; then + OUT="Disabled" else - OUT="Enabled" + OUT="Enabled" fi echo "$OUT" diff --git a/scripts/xshot-select-upload.sh b/scripts/xshot-select-upload.sh index 040251e..70c08c4 100755 --- a/scripts/xshot-select-upload.sh +++ b/scripts/xshot-select-upload.sh @@ -2,6 +2,6 @@ PIC="$HOME/pictures/screenshots/$(date +%Y-%m-%d_%H-%M-%S).png" -maim --format=png --hidecursor --quality 8 --select "$PIC" && \ - curl --form "file=@$PIC" "https://0x0.st" | \ - xclip -quiet +maim --format=png --hidecursor --quality 8 --select "$PIC" && + curl --form "file=@$PIC" "https://0x0.st" | + xclip -quiet diff --git a/scripts/xshot-upload.sh b/scripts/xshot-upload.sh index ed037de..17b614a 100755 --- a/scripts/xshot-upload.sh +++ b/scripts/xshot-upload.sh @@ -2,6 +2,6 @@ PIC="$HOME/pictures/screenshots/$(date +%Y-%m-%d_%H-%M-%S).png" -maim --format=png --hidecursor --quality 8 "$PIC" && \ - curl --form "file=@$PIC" "https://0x0.st" | \ - xclip -quiet +maim --format=png --hidecursor --quality 8 "$PIC" && + curl --form "file=@$PIC" "https://0x0.st" | + xclip -quiet diff --git a/src/lib/XMonad/Custom/Config.hs b/src/lib/XMonad/Custom/Config.hs index 84f4069..4a4af2d 100644 --- a/src/lib/XMonad/Custom/Config.hs +++ b/src/lib/XMonad/Custom/Config.hs @@ -11,8 +11,8 @@ -- module XMonad.Custom.Config - ( myConfig - ) where + ( myConfig + ) where import Flow import XMonad @@ -31,24 +31,24 @@ import XMonad.Hooks.UrgencyHook import XMonad.Layout.IndependentScreens myConfig = do - screens <- countScreens - def { borderWidth = C.border - , workspaces = C.myWorkspaces screens - , layoutHook = C.layoutHook - , terminal = C.term C.applications - , normalBorderColor = C.colorN - , focusedBorderColor = C.colorF - , modMask = C.modMask - , keys = C.keys - , mouseBindings = C.mouseBindings - , manageHook = C.manageHook - , handleEventHook = C.handleEventHook - , focusFollowsMouse = False - , clickJustFocuses = False - } - |> withUrgencyHook (borderUrgencyHook C.red1) - |> withNavigation2DConfig C.myNavigation2DConfig - |> ewmh - |> ewmhFullscreen - |> docks - |> (return :: a -> IO a) + screens <- countScreens + def { borderWidth = C.border + , workspaces = C.myWorkspaces screens + , layoutHook = C.layoutHook + , terminal = C.term C.applications + , normalBorderColor = C.colorN + , focusedBorderColor = C.colorF + , modMask = C.modMask + , keys = C.keys + , mouseBindings = C.mouseBindings + , manageHook = C.manageHook + , handleEventHook = C.handleEventHook + , focusFollowsMouse = False + , clickJustFocuses = False + } + |> withUrgencyHook (borderUrgencyHook C.red1) + |> withNavigation2DConfig C.myNavigation2DConfig + |> ewmh + |> ewmhFullscreen + |> docks + |> (return :: a -> IO a) diff --git a/test.sh b/test.sh index fd86536..3fe68f2 100755 --- a/test.sh +++ b/test.sh @@ -22,28 +22,28 @@ DISPLAY_NUMBER=5 ################################################################################ while getopts "hs:" o; do case "${o}" in - d) - SCREEN_SIZE=$OPTARG - ;; - - h) - usage - exit - ;; - - n) - DISPLAY_NUMBER=$OPTARG - ;; - - s) - SCREENS=$OPTARG - ;; - - *) - echo - usage - exit 1 - ;; + d) + SCREEN_SIZE=$OPTARG + ;; + + h) + usage + exit + ;; + + n) + DISPLAY_NUMBER=$OPTARG + ;; + + s) + SCREENS=$OPTARG + ;; + + *) + echo + usage + exit 1 + ;; esac done diff --git a/treefmt.toml b/treefmt.toml new file mode 100644 index 0000000..ff039ef --- /dev/null +++ b/treefmt.toml @@ -0,0 +1,24 @@ +[formatter.haskell] +command = "" +includes = ["*.hs"] + +[formatter.shell] +command = "/bin/sh" +options = [ + "-euc", + """ +shellcheck "$@" +shfmt -s -w "$@" + """, + "--", +] +includes = ["*.sh"] + +[formatter.prettier] +command = "prettier" +options = ["--write"] +includes = ["*.yaml"] + +[formatter.nix] +command = "nixfmt" +includes = ["*.nix"] |