diff --git a/flake.lock b/flake.lock index bddcdd6..8a02b4d 100644 --- a/flake.lock +++ b/flake.lock @@ -103,6 +103,22 @@ } }, "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { "flake": false, "locked": { "lastModified": 1668681692, @@ -136,6 +152,45 @@ "type": "github" } }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1703887061, + "narHash": "sha256-gGPa9qWNc6eCXT/+Z5/zMkyYOuRZqeFZBDbopNZQkuY=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "43e1aa1308018f37118e34d3a9cb4f5e75dc11d5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -362,6 +417,22 @@ "type": "github" } }, + "nixpkgs-stable_2": { + "locked": { + "lastModified": 1704874635, + "narHash": "sha256-YWuCrtsty5vVZvu+7BchAxmcYzTMfolSPP5io8+WYCg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3dc440faeee9e889fe2d1b4d25ad0f430d449356", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-unstable": { "locked": { "lastModified": 1705316053, @@ -441,6 +512,30 @@ "type": "gitlab" } }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils_2", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable_2" + }, + "locked": { + "lastModified": 1708018599, + "narHash": "sha256-M+Ng6+SePmA8g06CmUZWi1AjG2tFBX9WCXElBHEKnyM=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "5df5a70ad7575f6601d91f0efec95dd9bc619431", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "root": { "inputs": { "agenix": "agenix", @@ -452,13 +547,14 @@ "nixpkgs": "nixpkgs", "nixpkgs-droid": "nixpkgs-droid", "nixpkgs-unstable": "nixpkgs-unstable", + "pre-commit-hooks": "pre-commit-hooks", "snm": "snm" } }, "snm": { "inputs": { "blobs": "blobs", - "flake-compat": "flake-compat", + "flake-compat": "flake-compat_2", "nixpkgs": "nixpkgs_2", "nixpkgs-22_11": "nixpkgs-22_11", "nixpkgs-23_05": "nixpkgs-23_05", @@ -494,6 +590,21 @@ "type": "github" } }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "utils": { "locked": { "lastModified": 1659877975, diff --git a/flake.nix b/flake.nix index 25fae28..43fc420 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,9 @@ nixpkgs-droid.url = "github:NixOS/nixpkgs/nixos-23.05"; nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; + pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix"; + pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs"; + home-manager = { url = "github:nix-community/home-manager/release-23.11"; inputs.nixpkgs.follows = "nixpkgs"; @@ -45,51 +48,94 @@ disko.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = { home-manager, nixpkgs, nixpkgs-unstable, ... }@inputs: { - nixosConfigurations."thrall" = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = { inherit inputs; }; - modules = let - postfix-overlay = final: prev: { - postfix = nixpkgs-unstable.legacyPackages."x86_64-linux".postfix; - }; - in [ - ({ inputs, lib, ... }: { - nixpkgs = { - config.allowUnfree = true; - overlays = with inputs; [ emacs.overlay postfix-overlay ]; + outputs = { self, home-manager, nixpkgs, nixpkgs-unstable, pre-commit-hooks + , ... }@inputs: { + checks."x86_64-linux" = let + system = "x86_64-linux"; + pkgs = import nixpkgs { inherit system; }; + in { + pre-commit-check = pre-commit-hooks.lib.${system}.run { + src = ./.; + settings = { ormolu.defaultExtensions = [ "GHC2021" ]; }; + tools.fourmolu = pkgs.haskellPackages.fourmolu; + hooks = { + nixfmt.enable = true; + fourmolu.enable = true; + hpack.enable = true; + hlint.enable = true; }; - nix.registry = lib.mapAttrs (_: value: { flake = value; }) inputs; - }) - ./hosts/thrall - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.alex = import ./home/alex/cli.nix; - } - ]; - }; + }; + }; - nixosConfigurations."dregil" = nixpkgs-unstable.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = { inherit inputs; }; - modules = [ ./hosts/dregil ]; - }; - - nixosConfigurations."igor" = nixpkgs-unstable.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = { inherit inputs; }; - modules = [ ./hosts/igor ]; - }; - - nixOnDroidConfigurations.default = with inputs; - nix-on-droid.lib.nixOnDroidConfiguration { - modules = [ - ./hosts/redmi - { nix.registry.nixpkgs.flake = nixpkgs-droid; } - { nix.nixPath = [ "nixpkgs=${nixpkgs-droid}" ]; } + nixosConfigurations."thrall" = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { inherit inputs; }; + modules = let + postfix-overlay = final: prev: { + postfix = nixpkgs-unstable.legacyPackages."x86_64-linux".postfix; + }; + in [ + ({ inputs, lib, ... }: { + nixpkgs = { + config.allowUnfree = true; + overlays = with inputs; [ emacs.overlay postfix-overlay ]; + }; + nix.registry = lib.mapAttrs (_: value: { flake = value; }) inputs; + }) + ./hosts/thrall + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.alex = import ./home/alex/cli.nix; + } ]; }; - }; + + nixosConfigurations."dregil" = nixpkgs-unstable.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { inherit inputs; }; + modules = [ ./hosts/dregil ]; + }; + + nixosConfigurations."igor" = nixpkgs-unstable.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { inherit inputs; }; + modules = [ ./hosts/igor ]; + }; + + nixOnDroidConfigurations.default = with inputs; + nix-on-droid.lib.nixOnDroidConfiguration { + modules = [ + ./hosts/redmi + { nix.registry.nixpkgs.flake = nixpkgs-droid; } + { nix.nixPath = [ "nixpkgs=${nixpkgs-droid}" ]; } + ]; + }; + + devShells."x86_64-linux".default = let + system = "x86_64-linux"; + pkgs = import nixpkgs { inherit system; }; + in pkgs.haskellPackages.shellFor { + inherit (self.checks.${system}.pre-commit-check) shellHook; + + packages = p: [ p.xmonad p.xmonad-contrib ]; + + withHoogle = true; + + nativeBuildInputs = with pkgs; [ + haskellPackages.haskell-language-server + haskellPackages.fourmolu + haskellPackages.hspec-discover + haskellPackages.doctest + haskellPackages.xmonad + haskellPackages.xmonad-contrib + cabal-install + ghcid + nixfmt + hpack + hlint + ]; + }; + }; } diff --git a/home/alex/programs/emacs/doom/config.el b/home/alex/programs/emacs/doom/config.el index 78d7db8..59a8ef2 100644 --- a/home/alex/programs/emacs/doom/config.el +++ b/home/alex/programs/emacs/doom/config.el @@ -121,11 +121,11 @@ ;; will define elisp functions for the given lsp code actions, prefixing the ;; given function names with "lsp" -(lsp-make-interactive-code-action wingman-fill-hole "refactor.wingman.fillHole") -(lsp-make-interactive-code-action wingman-case-split "refactor.wingman.caseSplit") -(lsp-make-interactive-code-action wingman-refine "refactor.wingman.refine") -(lsp-make-interactive-code-action wingman-split-func-args "refactor.wingman.spltFuncArgs") -(lsp-make-interactive-code-action wingman-use-constructor "refactor.wingman.useConstructor") +;;(lsp-make-interactive-code-action wingman-fill-hole "refactor.wingman.fillHole") +;;(lsp-make-interactive-code-action wingman-case-split "refactor.wingman.caseSplit") +;;(lsp-make-interactive-code-action wingman-refine "refactor.wingman.refine") +;;(lsp-make-interactive-code-action wingman-split-func-args "refactor.wingman.spltFuncArgs") +;;(lsp-make-interactive-code-action wingman-use-constructor "refactor.wingman.useConstructor") ;; example key bindings ;; (define-key haskell-mode-map (kbd "C-c d") #'lsp-wingman-case-split) diff --git a/modules/wm/xmonad/config.hs b/modules/wm/xmonad/config.hs index 0287136..c9908cf 100644 --- a/modules/wm/xmonad/config.hs +++ b/modules/wm/xmonad/config.hs @@ -1,44 +1,39 @@ import XMonad +import XMonad.Actions.CycleWS qualified as WS import XMonad.Actions.Navigation2D (navigation2DP, windowGo, windowSwap) -import qualified XMonad.Actions.CycleWS as WS -import XMonad.Util.Ungrab (unGrab) -import XMonad.Layout.ThreeColumns -import XMonad.Layout.ToggleLayouts (ToggleLayout(..), toggleLayouts) +import XMonad.Hooks.EwmhDesktops +import XMonad.Hooks.ManageDocks qualified as Docks +import XMonad.Hooks.SetWMName import XMonad.Layout.BinarySpacePartition import XMonad.Layout.BorderResize (borderResize) -import XMonad.Hooks.EwmhDesktops -import XMonad.Hooks.SetWMName -import qualified XMonad.Hooks.ManageDocks as Docks -import qualified XMonad.Util.EZConfig as EZ +import XMonad.Layout.ThreeColumns +import XMonad.Layout.ToggleLayouts (ToggleLayout (..), toggleLayouts) +import XMonad.Util.EZConfig qualified as EZ +import XMonad.Util.Ungrab (unGrab) -import Numeric.Natural import Control.Monad (when) -import Text.Printf (printf) -import System.Posix.Process (executeFile) -import System.Info (arch,os) +import Numeric.Natural import System.Environment (getArgs) import System.FilePath (()) +import System.Info (arch, os) +import System.Posix.Process (executeFile) +import Text.Printf (printf) compiledConfig = printf "xmonad-%s-%s" arch os compileRestart resume = do - dirs <- asks directories - whenX (recompile dirs True) $ do - when resume writeStateToFile - catchIO - ( do - args <- getArgs - executeFile (cacheDir dirs compiledConfig) False args Nothing - ) + dirs <- asks directories + whenX (recompile dirs True) $ do + when resume writeStateToFile + catchIO + ( do + args <- getArgs + executeFile (cacheDir dirs compiledConfig) False args Nothing + ) -myLayout = borderResize $ Docks.avoidStruts $ layout +myLayout = borderResize $ Docks.avoidStruts layout where - layout = (emptyBSP ||| columns ||| tiled ||| Full) - tiled = Tall nmaster delta ratio - columns = ThreeColMid nmaster delta ratio - nmaster = 1 -- default number of windows in the master pane - ratio = 1/2 -- default proportion occupied by master pane - delta = 3/100 -- percent of screen to increment when resizing + layout = emptyBSP ||| Full main :: IO () main = getDirectories >>= launch myConfig @@ -48,66 +43,67 @@ main = getDirectories >>= launch myConfig windowMoveSplit :: Direction2D -> Bool -> X () windowMoveSplit direction _ = sendMessage $ MoveSplit direction -data VolumeCommand = ToggleVolume - | LowerVolume Natural - | RaiseVolume Natural +data VolumeCommand + = ToggleVolume + | LowerVolume Natural + | RaiseVolume Natural interpretVolumeCommand :: VolumeCommand -> String interpretVolumeCommand command = "amixer -q set Master " <> cmd where cmd = case command of - ToggleVolume -> "toggle" - LowerVolume delta -> show delta <> "%-" - RaiseVolume delta -> show delta <> "%+" + ToggleVolume -> "toggle" + LowerVolume delta -> show delta <> "%-" + RaiseVolume delta -> show delta <> "%+" changeVolume :: VolumeCommand -> X () changeVolume = spawn . interpretVolumeCommand -myConfig = ewmhFullscreen $ ewmh $ Docks.docks $ nav $ def - { modMask = mod4Mask -- Use Super instead of Alt - , terminal = "alacritty" - , layoutHook = myLayout - -- this seems to be necessary to make java gui applications work :( - , startupHook = ewmhDesktopsStartup >> setWMName "LG3D" - } - `EZ.additionalKeysP` - [ ("M-S-z", spawn "xscreensaver-command -lock") - , ("M-S-r", compileRestart True) - , ("M-S-q", restart "xmonad" True) - , ("M-C-s", unGrab *> spawn "scrot -s") - , ("M-b", sendMessage Docks.ToggleStruts) - , ("M-f", sendMessage (Toggle "Full")) - , ("M-p", spawn appLauncher) - , ("M-i", spawn passLauncher) - , ("M-w", kill) - , ("M-l", WS.toggleWS) - , ("M-g", WS.prevWS) - , ("M-r", WS.nextWS) +myConfig = + Docks.docks + . ewmh + . ewmhFullscreen + . nav + $ def + { modMask = mod4Mask -- Use Super instead of Alt + , terminal = "alacritty" + , layoutHook = myLayout + , -- this seems to be necessary to make java gui applications work :( + startupHook = ewmhDesktopsStartup >> setWMName "LG3D" + } + `EZ.additionalKeysP` [ ("M-S-z", spawn "xscreensaver-command -lock") + , ("M-S-r", compileRestart True) + , ("M-S-q", restart "xmonad" True) + , ("M-C-s", unGrab *> spawn "scrot -s") + , ("M-b", sendMessage Docks.ToggleStruts) + , ("M-f", sendMessage (Toggle "Full")) + , ("M-p", spawn appLauncher) + , ("M-i", spawn passLauncher) + , ("M-w", kill) + , ("M-l", WS.toggleWS) + , ("M-g", WS.prevWS) + , ("M-r", WS.nextWS) + , -- backlight control - -- backlight control + ("", spawn "xbacklight -dec 5") + , ("", spawn "xbacklight -inc 5") + , ("", spawn "xbacklight -dec 5") + , ("", spawn "xbacklight -inc 5") + , -- volume control - , ("", spawn "xbacklight -dec 5") - , ("", spawn "xbacklight -inc 5") - , ("", spawn "xbacklight -dec 5") - , ("", spawn "xbacklight -inc 5") - - -- volume control - - , ("", changeVolume ToggleVolume) - , ("", changeVolume $ LowerVolume 5) - , ("", changeVolume $ RaiseVolume 5) - - , ("M-a", sendMessage Balance) - , ("M-S-a", sendMessage Equalize) - , ("M-o", sendMessage Rotate) - ] + ("", changeVolume ToggleVolume) + , ("", changeVolume $ LowerVolume 5) + , ("", changeVolume $ RaiseVolume 5) + , ("M-a", sendMessage Balance) + , ("M-S-a", sendMessage Equalize) + , ("M-o", sendMessage Rotate) + ] where -- navigate using dvorak bindings nav = navigation2DP def ("c", "h", "t", "n") [("M-", windowGo), ("M-C-", windowSwap), ("M-S-", windowMoveSplit)] True appLauncher = "rofi -show combi -modes combi -combi-modes window,drun,run,ssh" passLauncher = "rofi-pass" - -- myManageHook :: ManageHook -- myManageHook = composeAll -- [ className =? "Gimp" --> doFloat