From 270252e5f8dc978bf23d699df4f2d3ebeec4bcb8 Mon Sep 17 00:00:00 2001 From: Andrea Ciceri Date: Fri, 19 Aug 2022 17:37:23 +0200 Subject: [PATCH] Working --- doom.d/config.el | 9 +-- doom.d/modules/os/exwm/config.el | 71 ++++++++++++-------- doom.d/packages.el | 3 +- flake.lock | 82 ++++++++++++++--------- flake.nix | 2 + hmModules/binance/default.nix | 3 + hmModules/discord/default.nix | 10 +++ hmModules/emacs/default.nix | 8 ++- hmModules/shell/default.nix | 25 +++---- hosts/thinkpad/default.nix | 5 ++ hosts/thinkpad/hardware-configuration.nix | 2 + modules/adb/default.nix | 9 +++ modules/battery/default.nix | 13 ++++ modules/bluetooth/default.nix | 6 ++ modules/ccr/default.nix | 1 + modules/exwm/default.nix | 4 +- modules/qmk-udev/default.nix | 3 + modules/ssh/default.nix | 3 + utils/default.nix | 3 +- 19 files changed, 178 insertions(+), 84 deletions(-) create mode 100644 hmModules/binance/default.nix create mode 100644 hmModules/discord/default.nix create mode 100644 modules/adb/default.nix create mode 100644 modules/battery/default.nix create mode 100644 modules/bluetooth/default.nix create mode 100644 modules/qmk-udev/default.nix create mode 100644 modules/ssh/default.nix diff --git a/doom.d/config.el b/doom.d/config.el index 772570d..65febdc 100644 --- a/doom.d/config.el +++ b/doom.d/config.el @@ -36,7 +36,7 @@ ;; This determines the style of line numbers in effect. If set to `nil', line ;; numbers are disabled. For relative line numbers, set this to `relative'. -(setq display-line-numbers-type 'relative) +(setq display-line-numbers-type 't) ;; If you use `org' and don't want your org files in the default location below, ;; change `org-directory'. It must be set before org loads! @@ -75,8 +75,9 @@ ;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how ;; they are implemented. -(use-package! pinentry - :init (setq epa-pinentry-mode `loopback) - (pinentry-start)) +(use-package! dirvish + :config (dirvish-override-dired-mode)) (setenv "SSH_AUTH_SOCK" "/run/user/1000/gnupg/S.gpg-agent.ssh") + +(set-formatter! 'nix-flake "nix --no-warn-dirty fmt -- --quiet" :modes '(nix-mode)) diff --git a/doom.d/modules/os/exwm/config.el b/doom.d/modules/os/exwm/config.el index 3bfc38f..9d0846c 100644 --- a/doom.d/modules/os/exwm/config.el +++ b/doom.d/modules/os/exwm/config.el @@ -16,13 +16,26 @@ ;; Confgure `exwm' the X window manager for emacs. (use-package! exwm :config + + ;(mapcar (lambda (i) (exwm-workspace-switch-create i) (number-sequence 0 9))) + ;(exwm-workspace-switch-create 1) + ;; Configure global key bindings. (setq exwm-input-global-keys `(([?\s-r] . exwm-reset) ([?\s-w] . exwm-workspace-switch) + ([?\s-q] . kill-this-buffer) + ([?\s-f] . exwm-layout-toggle-fullscreen) + ([?\s-c] . exwm-input-toggle-keyboard) ([?\s-d] . (lambda (command) (interactive (list (read-shell-command "$ "))) (start-process-shell-command command nil command))) + ,@(mapcar (lambda (i) + `(,(kbd (format "C-s-%d" i)) . + (lambda () + (interactive) + (exwm-workspace-move-window ,i)))) + (number-sequence 0 9)) ,@(mapcar (lambda (i) `(,(kbd (format "s-%d" i)) . (lambda () @@ -30,6 +43,9 @@ (exwm-workspace-switch-create ,i)))) (number-sequence 0 9)))) + (setq exwm-layout-show-all-buffers t) + (setq exwm-workspace-show-all-buffers t) + ;; Configure the default buffer behaviour. All buffers created in `exwm-mode' ;; are named "*EXWM*". Change it in `exwm-update-class-hook' and `exwm-update-title-hook' ;; which are run when a new X window class name or title is available. @@ -64,10 +80,7 @@ (add-hook 'exwm-update-title-hook 'exwm-rename-buffer) (require 'exwm-systemtray) - (exwm-systemtray-enable) - - ;; Enable the window manager. - (exwm-enable)) + (exwm-systemtray-enable)) ;; Use the `ido' configuration for a few configuration fixes that alter ;; 'C-x b' workplace switching behaviour. This also effects the functionality @@ -83,28 +96,32 @@ (use-package! exwm-randr :after exwm :config - (add-hook 'exwm-randr-screen-change-hook - (lambda () - (let ((xrandr-output-regexp "\n\\([^ ]+\\) connected ") - default-output) - (with-temp-buffer - (call-process "xrandr" nil t nil) - (goto-char (point-min)) - (re-search-forward xrandr-output-regexp nil 'noerror) - (setq default-output (match-string 1)) - (forward-line) - (if (not (re-search-forward xrandr-output-regexp nil 'noerror)) - (call-process - "xrandr" nil nil nil - "--output" default-output - "--auto") - (call-process - "xrandr" nil nil nil - "--output" (match-string 1) "--primary" "--auto" - "--output" default-output "--off" - ) - (setq exwm-randr-workspace-monitor-plist - (list 0 (match-string 1)))))))) + (setq exwm-randr-workspace-monitor-plist '(1 "DP-2" 2 "eDP-1")) + (setq exwm-workspace-warp-cursor t) + (setq mouse-autoselect-window t + focus-follows-mouse t) + ;; (add-hook 'exwm-randr-screen-change-hook + ;; (lambda () + ;; (let ((xrandr-output-regexp "\n\\([^ ]+\\) connected ") + ;; default-output) + ;; (with-temp-buffer + ;; (call-process "xrandr" nil t nil) + ;; (goto-char (point-min)) + ;; (re-search-forward xrandr-output-regexp nil 'noerror) + ;; (setq default-output (match-string 1)) + ;; (forward-line) + ;; (if (not (re-search-forward xrandr-output-regexp nil 'noerror)) + ;; (call-process + ;; "xrandr" nil nil nil + ;; "--output" default-output + ;; "--auto") + ;; (call-process + ;; "xrandr" nil nil nil + ;; "--output" (match-string 1) "--primary" "--auto" + ;; "--output" default-output "--off" + ;; ) + ;; (setq exwm-randr-workspace-monitor-plist + ;; (list 0 (match-string 1)))))))) (exwm-randr-enable)) ;; Configure the rudamentary status bar. @@ -132,4 +149,4 @@ (cl-pushnew k exwm-firefox-evil-firefox-class-name)) ;; Add the firefox buffer hook (add-hook 'exwm-manage-finish-hook - 'exwm-firefox-evil-activate-if-firefox)))) + 'exwm-firefox-evil-activate-if-firefox)))) diff --git a/doom.d/packages.el b/doom.d/packages.el index d800a98..1220203 100644 --- a/doom.d/packages.el +++ b/doom.d/packages.el @@ -49,4 +49,5 @@ ;; ...Or *all* packages (NOT RECOMMENDED; will likely break things) ;(unpin! t) -(package! pinentry) + +(package! dirvish) diff --git a/flake.lock b/flake.lock index cd03c88..714cb17 100644 --- a/flake.lock +++ b/flake.lock @@ -21,11 +21,11 @@ "doom-emacs": { "flake": false, "locked": { - "lastModified": 1657393840, - "narHash": "sha256-ISaIbqCNKKz9DhrTVKvDS40CzZiqICb2eDepGUdwYQA=", + "lastModified": 1659994866, + "narHash": "sha256-6lxvYfoPtzvinBHKvuUDpCz44IJpmZMLfLMy5q9UcFk=", "owner": "doomemacs", "repo": "doomemacs", - "rev": "33c5f3721a704c72e49efc5960be3785d1a80b81", + "rev": "b06fd63dcb686045d0c105f93e07f80cb8de6800", "type": "github" }, "original": { @@ -80,11 +80,11 @@ "ws-butler": "ws-butler" }, "locked": { - "lastModified": 1658470797, - "narHash": "sha256-ovk7xcjGqoXgc7fV4m0tlKhiuAglON4TKmt//Bd0fLE=", + "lastModified": 1660129951, + "narHash": "sha256-uY0fxCwUQ5LmfX2CoklqOebKl6GM96qir2Zv1cbHdQI=", "owner": "nix-community", "repo": "nix-doom-emacs", - "rev": "f7fd8620be427c6489f496645513d536e380c50c", + "rev": "20ca56a17dc33d67ed7d61b0e84205c617394b5b", "type": "github" }, "original": { @@ -96,11 +96,11 @@ "emacs-overlay": { "flake": false, "locked": { - "lastModified": 1658430126, - "narHash": "sha256-W5zw1NI7c47qT/FCkNAVmahA5On5UUs1pabAL6Tb2iI=", + "lastModified": 1659638214, + "narHash": "sha256-lXa01G06Ey9qgj+rYN7Nzc53FP3p2UMMnAuxpWXu9Ko=", "owner": "nix-community", "repo": "emacs-overlay", - "rev": "6c868dbad387da912e2a47f63a913c8a62555127", + "rev": "a151f9ff5b9fa813ac8918f3a3a67c643e7e2edc", "type": "github" }, "original": { @@ -276,11 +276,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1658238241, - "narHash": "sha256-naoSta79MYYRtVnIZhzq+YWgTOBhWE1Sr1AIhG7ZA9g=", + "lastModified": 1660505226, + "narHash": "sha256-Jl1w6X3qNfp0Y5PwRlz/tlhVa6Wzzceq1iScni3gb9s=", "owner": "nix-community", "repo": "home-manager", - "rev": "70d5929885ccec8dde8585894dd3ebe606e75f41", + "rev": "ff5133843c26979f8abb5dd801b32f40287692fa", "type": "github" }, "original": { @@ -305,6 +305,21 @@ "type": "github" } }, + "nixosHardware": { + "locked": { + "lastModified": 1660740642, + "narHash": "sha256-tTc3scY+8jG4eWOhrE1aWk2sJ2pu+KBE5axjP3h5zIA=", + "owner": "aciceri", + "repo": "nixos-hardware", + "rev": "21ad034e26eb6451d346b4a3de688042ccbff823", + "type": "github" + }, + "original": { + "owner": "aciceri", + "repo": "nixos-hardware", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1638587357, @@ -323,11 +338,11 @@ }, "nixpkgsStable": { "locked": { - "lastModified": 1658500284, - "narHash": "sha256-g7vwZ5UF8PvC9f2/7Zf5O6zxgJiMSuh1CiGZVuuOhEQ=", + "lastModified": 1660496378, + "narHash": "sha256-sgAhmrC1iSnl5T2VPPiMpciH1aRw5c7PYEdXX6jd6Gk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e3583ad6e533a9d8dd78f90bfa93812d390ea187", + "rev": "879121648fe522b38cc1cf75aef160a14a1f2e7b", "type": "github" }, "original": { @@ -339,11 +354,11 @@ }, "nixpkgsUnstable": { "locked": { - "lastModified": 1658380158, - "narHash": "sha256-DBunkegKWlxPZiOcw3/SNIFg93amkdGIy2g0y/jDpHg=", + "lastModified": 1660396586, + "narHash": "sha256-ePuWn7z/J5p2lO7YokOG1o01M0pDDVL3VrStaPpS5Ig=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a65b5b3f5504b8b89c196aba733bdf2b0bd13c16", + "rev": "e105167e98817ba9fe079c6c3c544c6ef188e276", "type": "github" }, "original": { @@ -355,11 +370,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1658397257, - "narHash": "sha256-2M1Ih3r8/mL8h0n8+PYoGXFazVY9zBcGJrNxNC3JgNo=", + "lastModified": 1659606041, + "narHash": "sha256-W4/u2ssr3fS4XOtltrsDD9w2kF4jYYZr6JyPGUW2jdI=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a174de16edfc6aa0893530b9a95d0bd0c2a952b7", + "rev": "5f9b871b72b24f066b1a1e189efd0669f2888c49", "type": "github" }, "original": { @@ -417,11 +432,11 @@ "org": { "flake": false, "locked": { - "lastModified": 1658412564, - "narHash": "sha256-JHiUjc4OAfPtNTWikVYEIkJkba9qV4N3QbtcJpjk4cM=", + "lastModified": 1659533964, + "narHash": "sha256-ipwJjcRzY9iqEjkG4m8EXZ6+8OMdANuXRnSwct2LByQ=", "owner": "emacs-straight", "repo": "org-mode", - "rev": "99681ce38937ba993a0407cee4fd6a7f869211bf", + "rev": "4702a73031c77ba03b480b0848c137d5d8773e07", "type": "github" }, "original": { @@ -433,11 +448,11 @@ "org-contrib": { "flake": false, "locked": { - "lastModified": 1652646857, - "narHash": "sha256-IWIShWyVnbwXqGLQaDNvJ0KoepxhIrXWTjPyGPEkQ14=", + "lastModified": 1659039737, + "narHash": "sha256-ig8pVl790DopN6ZrCTIrvojt5/0Y+aOsjE87pqIVz8M=", "owner": "emacsmirror", "repo": "org-contrib", - "rev": "c1e0980fd7a57ca2042fd78acfb1dfb5c3bc03fa", + "rev": "39e2abc5629c1be6186bb6489ec4f76524edf82a", "type": "github" }, "original": { @@ -484,11 +499,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1656169028, - "narHash": "sha256-y9DRauokIeVHM7d29lwT8A+0YoGUBXV3H0VErxQeA8s=", + "lastModified": 1659629599, + "narHash": "sha256-c9rvaqaH3HZo/C70E7rB18YSywa4ryTtN7CZ3cuCmoA=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "db3bd555d3a3ceab208bed48f983ccaa6a71a25e", + "rev": "6a9402e8f233de16536349d1dd3f4595c23386a4", "type": "github" }, "original": { @@ -518,6 +533,7 @@ "agenix": "agenix", "doomEmacs": "doomEmacs", "homeManager": "homeManager", + "nixosHardware": "nixosHardware", "nixpkgsStable": "nixpkgsStable", "nixpkgsUnstable": "nixpkgsUnstable", "preCommitHooks": "preCommitHooks" @@ -558,11 +574,11 @@ "ts-fold": { "flake": false, "locked": { - "lastModified": 1658223568, - "narHash": "sha256-HxUAg+MUbH8nNhKtRzZDeN/a/sCQHSpDRCK2nvvHp8g=", + "lastModified": 1659171920, + "narHash": "sha256-/yY3Ph/BE3PFZhnBIQIHkwOW/43phSI7WeoMvU83TG4=", "owner": "jcs-elpa", "repo": "ts-fold", - "rev": "ea554f10e79ed9846662b1639adc4b86783ecfc6", + "rev": "17d131f69a717d7e8cc6d3af9dfa7d2b5e2b78ef", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 14b4c87..f160aff 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,7 @@ inputs = { nixpkgsUnstable.url = github:NixOS/nixpkgs/nixos-unstable; nixpkgsStable.url = github:NixOS/nixpkgs/nixos-22.05; + nixosHardware.url = github:aciceri/nixos-hardware; homeManager = { url = github:nix-community/home-manager; inputs.nixpkgs.follows = "nixpkgsUnstable"; @@ -17,6 +18,7 @@ self, nixpkgsUnstable, nixpkgsStable, + nixosHardware, homeManager, preCommitHooks, agenix, diff --git a/hmModules/binance/default.nix b/hmModules/binance/default.nix new file mode 100644 index 0000000..c0aa5d2 --- /dev/null +++ b/hmModules/binance/default.nix @@ -0,0 +1,3 @@ +{pkgs, ...}: { + home.packages = [pkgs.binance]; +} diff --git a/hmModules/discord/default.nix b/hmModules/discord/default.nix new file mode 100644 index 0000000..4cf2416 --- /dev/null +++ b/hmModules/discord/default.nix @@ -0,0 +1,10 @@ +{ + pkgs, + lib, + ... +}: { + home.packages = [pkgs.discord]; + home.file.".config/discord/settings.json".text = builtins.toJSON { + SKIP_HOST_UPDATE = true; + }; +} diff --git a/hmModules/emacs/default.nix b/hmModules/emacs/default.nix index 2c4bc55..3ea9440 100644 --- a/hmModules/emacs/default.nix +++ b/hmModules/emacs/default.nix @@ -1,4 +1,8 @@ -{pkgs, ...}: { +{ + pkgs, + config, + ... +}: { programs.emacs.enable = true; programs.doom-emacs = { enable = true; @@ -8,6 +12,8 @@ services.emacs = { enable = true; + extraOptions = ["-f" "exwm-enable"]; + defaultEditor = true; }; home.packages = with pkgs; [ diff --git a/hmModules/shell/default.nix b/hmModules/shell/default.nix index d56e6ed..740a8e4 100644 --- a/hmModules/shell/default.nix +++ b/hmModules/shell/default.nix @@ -41,11 +41,6 @@ file = "share/zsh/themes/spaceship.zsh-theme"; src = pkgs.spaceship-prompt; } - { - name = "zsh-fzf-tab"; - file = "share/fzf-tab/fzf-tab.plugin.zsh"; - src = pkgs.zsh-fzf-tab; - } { name = "fast-zsh-syntax-highlighting"; file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh"; @@ -57,38 +52,36 @@ plugins = [ "git" "sudo" - "command-not-found" "colored-man-pages" "colorize" + "thefuck" + "fzf" ]; }; shellAliases = { - "pass-clone" = "[ -d .password-store ] && echo 'Password store archive already exists' || git clone git@git.sr.ht:~zrsk/pass ~/.password-store"; - "getpass" = "pass show $(find .password-store/ -name \"*.gpg\" | sed \"s/\\.password-store\\/\\(.*\\)\\.gpg$/\\1/g\" | fzf) | wl-copy; ((sleep 60 && wl-copy --clear) &)"; "cat" = "bat"; - "man" = "batman"; - "em" = "[[ -z \$XDG_CURRENT_DESKTOP ]] && emacsclient -c -nw || emacsclient -c"; "emw" = "emacsclient -c"; "emnw" = "emacsclient -c -nw"; }; localVariables = { PASSWORD_STORE_DIR = "/home/ccr/.password-store"; + SPACESHIP_CHAR_SYMBOL = "λ "; SPACESHIP_TIME_SHOW = "true"; SPACESHIP_USER_SHOW = "always"; SPACESHIP_HOST_SHOW = "always"; - EDITOR = "em"; NIX_BUILD_SHELL = "${pkgs.zsh-nix-shell}/scripts/buildShellShim.zsh"; PROMPT = "\\\${IN_NIX_SHELL:+[nix-shell] }$PROMPT"; }; loginExtra = "[[ -z $DISPLAY && $TTY = /dev/tty1 ]] && exec startx"; - initExtra = - if pkgs.stdenv.hostPlatform.isDarwin - then "if test -e /etc/static/bashrc; then source /etc/static/bashrc > /dev/null 2>&1; fi" - else ""; envExtra = '' [ $TERM = "dumb" ] && unsetopt zle && PS1='$ ' # for Emacs TRAMP mode ''; }; - programs.command-not-found.enable = true; + programs.nix-index = { + enable = true; + enableZshIntegration = true; + }; + + home.packages = with pkgs; [thefuck]; } diff --git a/hosts/thinkpad/default.nix b/hosts/thinkpad/default.nix index ae16cea..a40c162 100644 --- a/hosts/thinkpad/default.nix +++ b/hosts/thinkpad/default.nix @@ -15,6 +15,11 @@ "audio" "ccr" "exwm" + "battery" + "ssh" + "adb" + "qmk-udev" + "bluetooth" ]; boot.initrd.availableKernelModules = ["xhci_pci" "nvme" "usb_storage" "sd_mod"]; diff --git a/hosts/thinkpad/hardware-configuration.nix b/hosts/thinkpad/hardware-configuration.nix index d2fa703..a9b8bd1 100644 --- a/hosts/thinkpad/hardware-configuration.nix +++ b/hosts/thinkpad/hardware-configuration.nix @@ -70,4 +70,6 @@ powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + + services.throttled.enable = true; } diff --git a/modules/adb/default.nix b/modules/adb/default.nix new file mode 100644 index 0000000..85ded03 --- /dev/null +++ b/modules/adb/default.nix @@ -0,0 +1,9 @@ +{ + config, + lib, + pkgs, + ... +}: { + programs.adb.enable = true; + users.users.ccr.extraGroups = ["adbusers"]; +} diff --git a/modules/battery/default.nix b/modules/battery/default.nix new file mode 100644 index 0000000..2f56d8b --- /dev/null +++ b/modules/battery/default.nix @@ -0,0 +1,13 @@ +{config, ...}: { + services.tlp.enable = true; + + services.upower.enable = true; + + nixpkgs.overlays = [ + (self: super: { + tlp = super.tlp.override { + enableRDW = config.networkmanager.enable; + }; + }) + ]; +} diff --git a/modules/bluetooth/default.nix b/modules/bluetooth/default.nix new file mode 100644 index 0000000..67c24ce --- /dev/null +++ b/modules/bluetooth/default.nix @@ -0,0 +1,6 @@ +{pkgs, ...}: { + services.blueman.enable = true; + hardware.pulseaudio.enable = true; + hardware.bluetooth.enable = true; + services.dbus.packages = with pkgs; [blueman]; +} diff --git a/modules/ccr/default.nix b/modules/ccr/default.nix index 5f0a2c0..8feed2a 100644 --- a/modules/ccr/default.nix +++ b/modules/ccr/default.nix @@ -45,6 +45,7 @@ "vscode" "element" "udiskie" + "discord" ]; home.packages = with pkgs; [ ]; diff --git a/modules/exwm/default.nix b/modules/exwm/default.nix index 4118f37..cf56aa1 100644 --- a/modules/exwm/default.nix +++ b/modules/exwm/default.nix @@ -27,10 +27,12 @@ export QT_IM_MODULE=xim export CLUTTER_IM_MODULE=xim + dbus-update-activation-environment DISPLAY + # Lockscreen exec ${pkgs.xss-lock}/bin/xss-lock -- ${pkgs.i3lock-blur}/bin/i3lock-color & # Finally start Emacs - exec dbus-launch emacsclient --eval "(exwm-init)" --create-frame -F "((fullscreen . fullboth))" + exec dbus-launch emacsclient --create-frame -F "((fullscreen . fullboth))" ''; } diff --git a/modules/qmk-udev/default.nix b/modules/qmk-udev/default.nix new file mode 100644 index 0000000..8a9b4ba --- /dev/null +++ b/modules/qmk-udev/default.nix @@ -0,0 +1,3 @@ +{pkgs, ...}: { + services.udev.packages = [pkgs.qmk-udev-rules]; +} diff --git a/modules/ssh/default.nix b/modules/ssh/default.nix new file mode 100644 index 0000000..c3dc07a --- /dev/null +++ b/modules/ssh/default.nix @@ -0,0 +1,3 @@ +{ + services.sshd.enable = true; +} diff --git a/utils/default.nix b/utils/default.nix index 4306ef7..ed2e457 100644 --- a/utils/default.nix +++ b/utils/default.nix @@ -1,5 +1,6 @@ { nixpkgsUnstable, + nixosHardware, preCommitHooks, homeManager, doomEmacs, @@ -48,7 +49,7 @@ thinkpad = mkConfiguration { name = "thinkpad"; system = supportedSystems.x86_64-linux; - modules = []; + modules = [nixosHardware.nixosModules.lenovo-thinkpad-x1-7th-gen]; }; };