From 13ad21f74ccb1f38bc090e61dd9047b01e376836 Mon Sep 17 00:00:00 2001 From: Andrea Ciceri Date: Sat, 29 Oct 2022 12:02:40 +0200 Subject: [PATCH] Too much stuff --- doom.d/config.el | 10 ++-- doom.d/modules/.gitkeep | 0 flake.lock | 56 +++++++++++++++-------- hmModules/digikam/default.nix | 3 ++ hmModules/emacs/default.nix | 71 +++++++++++++++++++++++++++-- hmModules/firefox/default.nix | 11 +++++ hosts/hs/default.nix | 20 ++++++++ hosts/thinkpad/default.nix | 52 +++++++++++---------- modules/wireguardClient/default.nix | 64 ++++++++++++++++++++++++++ 9 files changed, 234 insertions(+), 53 deletions(-) create mode 100644 doom.d/modules/.gitkeep create mode 100644 hmModules/digikam/default.nix create mode 100644 modules/wireguardClient/default.nix diff --git a/doom.d/config.el b/doom.d/config.el index 64a0c89..feb2006 100644 --- a/doom.d/config.el +++ b/doom.d/config.el @@ -75,9 +75,6 @@ ;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how ;; they are implemented. -(use-package! dirvish - :config (dirvish-override-dired-mode)) - (setenv "SSH_AUTH_SOCK" "/run/user/1000/gnupg/S.gpg-agent.ssh") (set-formatter! 'nix-flake "nixFormat 2>/dev/null" :modes '(nix-mode)) @@ -90,4 +87,9 @@ (setq org-roam-directory (file-truename "~/roam")) (org-roam-db-autosync-mode) -(setq +tree-sitter-hl-enabled-modes t) +(setq doom-font (font-spec :family "Fira Code" :size 16) + doom-variable-pitch-font (font-spec :family "Fira Code") + doom-big-font-increment 1) + +(dotimes (workspace-number 10) + (define-key vterm-mode-map (kbd (format "M-%d" workspace-number)) nil)) diff --git a/doom.d/modules/.gitkeep b/doom.d/modules/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/flake.lock b/flake.lock index 2156cc2..cfbcaf1 100644 --- a/flake.lock +++ b/flake.lock @@ -42,17 +42,34 @@ "doom-emacs": { "flake": false, "locked": { - "lastModified": 1660901074, - "narHash": "sha256-3apl0eQlfBj3y0gDdoPp2M6PXYnhxs0QWOHp8B8A9sc=", + "lastModified": 1662497747, + "narHash": "sha256-4n7E1fqda7cn5/F2jTkOnKw1juG6XMS/FI9gqODL3aU=", "owner": "doomemacs", "repo": "doomemacs", - "rev": "c44bc81a05f3758ceaa28921dd9c830b9c571e61", + "rev": "3853dff5e11655e858d0bfae64b70cb12ef685ac", "type": "github" }, "original": { "owner": "doomemacs", - "ref": "master", "repo": "doomemacs", + "rev": "3853dff5e11655e858d0bfae64b70cb12ef685ac", + "type": "github" + } + }, + "doom-modeline": { + "flake": false, + "locked": { + "lastModified": 1648449595, + "narHash": "sha256-HjULFxtNDAJ7PDpy/e2bhoDYgBjwGpBdBoTY135puYA=", + "owner": "seagle0128", + "repo": "doom-modeline", + "rev": "ce9899f00af40edb78f58b9af5c3685d67c8eed2", + "type": "github" + }, + "original": { + "owner": "seagle0128", + "repo": "doom-modeline", + "rev": "ce9899f00af40edb78f58b9af5c3685d67c8eed2", "type": "github" } }, @@ -75,6 +92,7 @@ "doomEmacs": { "inputs": { "doom-emacs": "doom-emacs", + "doom-modeline": "doom-modeline", "doom-snippets": "doom-snippets", "emacs-overlay": "emacs-overlay", "emacs-so-long": "emacs-so-long", @@ -101,11 +119,11 @@ "ws-butler": "ws-butler" }, "locked": { - "lastModified": 1664622347, - "narHash": "sha256-pJTnEG68PhrXjpkfz/784BlcxaHgV06b1cUVGRxhMdw=", + "lastModified": 1666731850, + "narHash": "sha256-yyCrh5vPqxJNj+2wt4IxHAk7blnYxwC/zkSKw/y0hg8=", "owner": "nix-community", "repo": "nix-doom-emacs", - "rev": "b65e204ce9d20b376acc38ec205d08007eccdaef", + "rev": "17673891a41c747d485b9407cb3b50b3156395ee", "type": "github" }, "original": { @@ -117,11 +135,11 @@ "emacs-overlay": { "flake": false, "locked": { - "lastModified": 1664478431, - "narHash": "sha256-XTPklm/+e2UfIitB0+s/fKTheMJSw3G1p+t0SsBCuo4=", + "lastModified": 1666298449, + "narHash": "sha256-y1SRRRK2eTVuh/HRCxwDSInMwGv0d5cPIp4YDlbcM30=", "owner": "nix-community", "repo": "emacs-overlay", - "rev": "6c78924bc5b6daaf98c0dbe63bdfcf80e6433f4b", + "rev": "b8e24cec99ff68f8a875b6f842a10b6b2ab398d3", "type": "github" }, "original": { @@ -445,11 +463,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1664435807, - "narHash": "sha256-sYOAzHDloPQH48Nmp2hFf7mvVRv+AOlfQXNaCeBTykE=", + "lastModified": 1666275482, + "narHash": "sha256-P5cxOmp1Yi2miEDLQas8GLQQ4W54zYgHd2frvs+lERQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "8ba120420fbdd9bd35b3a5366fa0206d8c99ade3", + "rev": "d639b2dfacdb3464faa11936a8c751ea3ff57775", "type": "github" }, "original": { @@ -507,11 +525,11 @@ "org": { "flake": false, "locked": { - "lastModified": 1664493874, - "narHash": "sha256-8zLosjfQX0aR5HprtCeiSqN1pfB+GEUF9AULk6WRcR4=", + "lastModified": 1666258795, + "narHash": "sha256-k2FbWk4OJKZbih3pTvJYxkaXuauWsuaXXthV54UFqCM=", "owner": "emacs-straight", "repo": "org-mode", - "rev": "fe1f4f2ccf040deff9c57288d987f17cc2da321f", + "rev": "98cae03b7d9a612334d5ea461e73ac0b37b0285d", "type": "github" }, "original": { @@ -590,11 +608,11 @@ "revealjs": { "flake": false, "locked": { - "lastModified": 1664012352, - "narHash": "sha256-Pu5p6HqIO2wvWiTEhsQyIuwlWEIa1GjO3EDXosznyYE=", + "lastModified": 1665992801, + "narHash": "sha256-bqNgaBT6WPfumhdG1VPZ6ngn0QA9RDuVtVJtVwxbOd4=", "owner": "hakimel", "repo": "reveal.js", - "rev": "468132320d6e072abd1297d7cc24766a2b7a832d", + "rev": "f6f657b627f9703e32414d8d3f16fb49d41031cb", "type": "github" }, "original": { diff --git a/hmModules/digikam/default.nix b/hmModules/digikam/default.nix new file mode 100644 index 0000000..928dde1 --- /dev/null +++ b/hmModules/digikam/default.nix @@ -0,0 +1,3 @@ +{pkgs, ...}: { + home.packages = [pkgs.digikam]; +} diff --git a/hmModules/emacs/default.nix b/hmModules/emacs/default.nix index b76525a..cb44bde 100644 --- a/hmModules/emacs/default.nix +++ b/hmModules/emacs/default.nix @@ -3,20 +3,81 @@ config, lib, ... -}: { - programs.emacs = { - enable = true; - package = lib.mkForce (pkgs.emacs28NativeComp.override { - # FIXME `mkForce` shouldn't be needed +}: let + rev = "72a94f91fd0570556ce770dc3a39e658f7588f7e"; # Current master, Emacs 29, seems a good commit + sha256 = "e5kKIEZJB9BGbBvGtiPK3gNygFoGxkG02nRLCwnGtmk="; + emacsMaster = + (pkgs.emacs.override { nativeComp = true; + withPgtk = true; withSQLite3 = true; withGTK3 = true; + }) + .overrideAttrs (old: { + src = pkgs.fetchFromSavannah { + repo = "emacs"; + inherit rev sha256; + }; + version = rev; + patches = []; + postPatch = + old.postPatch + + '' + substituteInPlace lisp/loadup.el \ + --replace '(emacs-repository-get-version)' '"${rev}"' \ + --replace '(emacs-repository-get-branch)' '"master"' + '' + + (lib.optionalString (old ? NATIVE_FULL_AOT) + # TODO: remove when https://github.com/NixOS/nixpkgs/pull/193621 is merged + ( + let + backendPath = + lib.concatStringsSep " " + (builtins.map (x: ''\"-B${x}\"'') [ + # Paths necessary so the JIT compiler finds its libraries: + "${lib.getLib pkgs.libgccjit}/lib" + "${lib.getLib pkgs.libgccjit}/lib/gcc" + "${lib.getLib pkgs.stdenv.cc.libc}/lib" + + # Executable paths necessary for compilation (ld, as): + "${lib.getBin pkgs.stdenv.cc.cc}/bin" + "${lib.getBin pkgs.stdenv.cc.bintools}/bin" + "${lib.getBin pkgs.stdenv.cc.bintools.bintools}/bin" + ]); + in '' + substituteInPlace lisp/emacs-lisp/comp.el --replace \ + "(defcustom comp-libgccjit-reproducer nil" \ + "(setq native-comp-driver-options '(${backendPath})) (defcustom comp-libgccjit-reproducer nil" + '' + )); }); +in { + programs.emacs = { + enable = true; }; programs.doom-emacs = { enable = true; + emacsPackage = emacsMaster; doomPrivateDir = ../../doom.d; + doomPackageDir = pkgs.linkFarm "my-doom-packages" [ + { + name = "config.el"; + path = ../../doom.d/config.el; + } + { + name = "init.el"; + path = ../../doom.d/init.el; + } + { + name = "packages.el"; + path = ../../doom.d/packages.el; + } + { + name = "modules"; + path = ../../doom.d/modules; + } + ]; }; services.emacs = { diff --git a/hmModules/firefox/default.nix b/hmModules/firefox/default.nix index 876afd3..705ff31 100644 --- a/hmModules/firefox/default.nix +++ b/hmModules/firefox/default.nix @@ -1,6 +1,12 @@ {pkgs, ...}: { programs.firefox = { enable = true; + package = pkgs.wrapFirefox pkgs.firefox-unwrapped { + forceWayland = true; + extraPolicies = { + ExtensionSettings = {}; + }; + }; profiles.ccr = { settings = { "browser.startup.homepage" = "https://google.it"; @@ -15,4 +21,9 @@ }; }; }; + home.sessionVariables = { + MOZ_ENABLE_WAYLAND = 1; + XDG_CURRENT_DESKTOP = "sway"; + NIXOS_OZONE_WL = 1; + }; } diff --git a/hosts/hs/default.nix b/hosts/hs/default.nix index e771feb..ba3a3ed 100644 --- a/hosts/hs/default.nix +++ b/hosts/hs/default.nix @@ -248,6 +248,15 @@ proxyPass = "http://192.168.1.71:80"; }; }; + + "wstunnel.ccr.ydns.eu" = { + enableACME = true; + addSSL = true; + locations."/" = { + proxyPass = "http://localhost:8080"; + proxyWebsockets = true; + }; + }; }; }; }; @@ -275,6 +284,17 @@ }; }; + systemd.services.wstunnel = { + description = "WSTunnel"; + wantedBy = ["multi-user.target"]; + after = ["network.target"]; + serviceConfig = { + User = "root"; + Type = "oneshot"; + ExecStart = "${pkgs.wstunnel}/bin/wstunnel wstunnel --server ws://0.0.0.0:8080"; + }; + }; + # TODO It seems to not work systemd.timers.ydnsUpdater = { wantedBy = ["timers.target"]; diff --git a/hosts/thinkpad/default.nix b/hosts/thinkpad/default.nix index 9a9e038..c5e8b88 100644 --- a/hosts/thinkpad/default.nix +++ b/hosts/thinkpad/default.nix @@ -11,46 +11,48 @@ ./hardware-configuration.nix ] ++ fleetModules [ - "common" - "ccr" - "fonts" - "dbus" + "adb" "audio" "battery" - "ssh" - "adb" - "qmk-udev" - "bluetooth" - "docker" - "transmission" - "fprintd" "binfmt" - "udisks2" + "bluetooth" + "ccr" + "common" + "dbus" + "docker" + "fonts" + "fprintd" "printing" + "qmk-udev" + "ssh" + "transmission" + "udisks2" + "xdg" ]; ccr = { enable = true; autologin = true; modules = [ - "shell" - "sway" + "chrome" + "cura" + "digikam" + "discord" + "element" "emacs" - "mpv" "firefox" - "qutebrowser" "git" "gpg" - "password-store" - "slack" - "chrome" - "vscode" - "element" - "udiskie" - "discord" - "cura" - "xdg" "helix" + "mpv" + "password-store" + "qutebrowser" + "shell" + "slack" + "sway" + "udiskie" + "vscode" + "xdg" ]; packages = with pkgs; [ comma diff --git a/modules/wireguardClient/default.nix b/modules/wireguardClient/default.nix new file mode 100644 index 0000000..a34e62d --- /dev/null +++ b/modules/wireguardClient/default.nix @@ -0,0 +1,64 @@ +# FIXME For some reson this doesnt' work +{ + config, + lib, + pkgs, + ... +}: { + networking.firewall = { + allowedUDPPorts = [51820]; # Clients and peers can use the same port, see listenport + }; + networking.wireguard.interfaces = { + # "wg0" is the network interface name. You can name the interface arbitrarily. + wg0 = { + # Determines the IP address and subnet of the client's end of the tunnel interface. + ips = ["10.100.0.2/24"]; + listenPort = 51820; # to match firewall allowedUDPPorts (without this wg uses random port numbers) + + # Path to the private key file. + # + # Note: The private key can also be included inline via the privateKey option, + # but this makes the private key world-readable; thus, using privateKeyFile is + # recommended. + privateKeyFile = "/home/ccr/wg-private"; #TODO use agenix + + peers = [ + # For a client configuration, one peer entry for the server will suffice. + + { + # Public key of the server (not a file path). + publicKey = "fCwjd75CefC9A7WqO7s3xfOk2nRcoTKfnAzDT6Lc5AA="; + + # Forward all the traffic via VPN. + allowedIPs = ["0.0.0.0/0"]; + # Or forward only particular subnets + #allowedIPs = [ "10.100.0.1" "91.108.12.0/22" ]; + + # Set this to the server IP and port. + endpoint = "ccr.ydns.eu:51820"; # ToDo: route to endpoint not automatically configured https://wiki.archlinux.org/index.php/WireGuard#Loop_routing https://discourse.nixos.org/t/solved-minimal-firewall-setup-for-wireguard-client/7577 + + # Send keepalives every 25 seconds. Important to keep NAT tables alive. + persistentKeepalive = 25; + } + ]; + }; + }; + + networking.wg-quick.interfaces = { + wg0 = { + address = ["10.0.0.2/24" "fdc9:281f:04d7:9ee9::2/64"]; + dns = ["10.0.0.1" "fdc9:281f:04d7:9ee9::1"]; + privateKeyFile = "/home/ccr/wg-private"; + + peers = [ + { + publicKey = "fCwjd75CefC9A7WqO7s3xfOk2nRcoTKfnAzDT6Lc5AA="; + # presharedKeyFile = "/root/wireguard-keys/preshared_from_peer0_key"; + allowedIPs = ["0.0.0.0/0" "::/0"]; + endpoint = "ccr.ydns.eu:51820"; + persistentKeepalive = 25; + } + ]; + }; + }; +}