From 9794a06c70a72e48970b60f21a2b6871b3b62d75 Mon Sep 17 00:00:00 2001 From: Tristan Druyen Date: Sun, 12 Nov 2023 21:16:35 +0100 Subject: [PATCH] WIP - add llama-cpp to emacs - add cachix to nixos config - remove unneeded homeConfigurations - Add emacs vterm+ tree sitter grammars - enable tree sitter for most doom layers - add emacs bg-transparency --- README.md | 6 --- ext/doom/config.el | 64 ++++++++++++++++++++++++- ext/doom/init.el | 26 ++++++---- flake.lock | 48 +++++++++---------- flake.nix | 42 +--------------- home-mods/shell/default.nix | 9 +++- os-mods/cachix/caches/ai.nix | 12 +++++ os-mods/cachix/caches/nix-community.nix | 12 +++++ os-mods/cachix/default.nix | 14 ++++++ systems/nixos-desk/default.nix | 1 + 10 files changed, 151 insertions(+), 83 deletions(-) create mode 100644 os-mods/cachix/caches/ai.nix create mode 100644 os-mods/cachix/caches/nix-community.nix create mode 100644 os-mods/cachix/default.nix diff --git a/README.md b/README.md index f77c357..66fe8e3 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,5 @@ # My nix conf -## 🏠 Home Setup - -```bash -nix run home-manager/release-23.05 -- switch --flake . -``` - ## 🏗️ System Setup ### 👷 "Manual" diff --git a/ext/doom/config.el b/ext/doom/config.el index d02abee..ab6ed21 100644 --- a/ext/doom/config.el +++ b/ext/doom/config.el @@ -98,9 +98,36 @@ ;; llama.cpp + +;; openchat prompt: GPT4 User: {prompt}<|end_of_turn|>GPT4 Assistant: + (use-package llama-cpp :ensure t) +;; (use-package llama-cpp-code) +;; (use-package llama-cpp-chat) + + +;; openchat +;; (setq! +;; llama-cpp-params '( +;; :n_predict -1 +;; :stop ["<|end_of_turn|>"] +;; ) + +;; llama-cpp-chat-prompt "System: +;; You are an intelligent programming assistant. +;; The User is a professional software developer, be concise in your answers and assume technical proficiency. +;; " +;; llama-cpp-chat-input-prefix " +;; GPT4User: +;; " +;; llama-cpp-chat-input-suffix " +;; <|end_of_turn|> +;; GPT4 Assistant: +;; ") + +;; Phind codellama : (setq! llama-cpp-chat-prompt "### System Prompt You are an intelligent programming assistant." llama-cpp-chat-input-prefix " @@ -112,8 +139,6 @@ You are an intelligent programming assistant." ### Assistant ") -;;(use-package llama-cpp-code) -;; (use-package llama-cpp-chat) ;; Nix @@ -126,6 +151,41 @@ You are an intelligent programming assistant." (setq-default vterm-shell (executable-find "fish")) +;; Background Transparency + Toggling + +(defun set-frame-bg-opacity (opacity) + ;Interactively change the current frames background opacity. + ; OPACITY is an integer between 0 to 100, inclusive. + (interactive + (list (read-number "Opacity (0-100): " + (or (frame-parameter nil 'alpha) + 100)))) + (set-frame-parameter nil 'alpha-background opacity)) + + +(defun toggle-bg-transparency () + ;Toggle between transparent and opaque background. + (interactive) + (let ((alpha-background (frame-parameter nil 'alpha-background))) + (set-frame-bg-opacity + (if (eql (cond + ((numberp alpha-background) alpha-background) + (t 100)) + 100) + 85 100) + ))) + +(map! :leader + (:prefix-map ("t" . "toggle") + (:prefix ("T" . "Transparancy") + :desc "Toggle background transparancy" "b" #'toggle-bg-transparency))) + +(defun setup-frame-transparency (frame) + (set-frame-parameter frame 'alpha-background 85)) + +(add-hook 'after-make-frame-functions #'setup-frame-transparency) + + ;; TABS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (use-package centaur-tabs :init diff --git a/ext/doom/init.el b/ext/doom/init.el index 541de0c..ef2e741 100644 --- a/ext/doom/init.el +++ b/ext/doom/init.el @@ -125,7 +125,8 @@ :lang ;;agda ; types of types of types of types... ;;beancount ; mind the GAAP - (cc +lsp) ; C > C++ == 1 + (cc +lsp + +tree-sitter) ; C > C++ == 1 ;;clojure ; java with a lisp ;;common-lisp ; if you've seen one lisp, you've seen them all ;;coq ; proofs-as-programs @@ -150,9 +151,12 @@ ;;(haskell +lsp) ; a language that's lazier than I am ;;hy ; readability of scheme w/ speed of python ;;idris ; a language you can depend on - json ; At least it ain't XML + (json + +tree-sitter) ; At least it ain't XML ;;(java +lsp) ; the poster child for carpal tunnel syndrome - ;;javascript ; all(hope(abandon(ye(who(enter(here)))))) + (javascript + +lsp + +tree-sitter) ; all(hope(abandon(ye(who(enter(here)))))) ;;julia ; a better, faster MATLAB ;;kotlin ; a better, slicker Java(Script) ;;latex ; writing papers in Emacs has never been so fun @@ -161,7 +165,8 @@ ;;lua ; one-based indices? one-based indices markdown ; writing docs for people to ignore ;;nim ; python + lisp at the speed of c - (nix +lsp) ; I hereby declare "nix geht mehr!" + (nix +lsp + +tree-sitter) ; I hereby declare "nix geht mehr!" ;;ocaml ; an objective camel (org ; organize your plain life in plain text +jupyter @@ -182,17 +187,22 @@ rest ; Emacs as a REST client ;;rst ; ReST in peace ;;(ruby +rails) ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"} - (rust +lsp) ; Fe2O3.unwrap().unwrap().unwrap().unwrap() + (rust +lsp + +tree-sitter) ; Fe2O3.unwrap().unwrap().unwrap().unwrap() ;;scala ; java, but good ;;(scheme +guile) ; a fully conniving family of lisps - sh ; she sells {ba,z,fi}sh shells on the C xor + (sh +tree-sitter) ; she sells {ba,z,fi}sh shells on the C xor ;;sml ;;solidity ; do you need a blockchain? No. ;;swift ; who asked for emoji variables? ;;terra ; Earth and Moon in alignment for performance. (web - +css) ; the tubes - yaml ; JSON, but readable + +css + +lsp + +tree-sitter) ; the tubes + (yaml + +tree-sitter + +lsp) ; JSON, but readable ;;zig ; C, but simpler :email diff --git a/flake.lock b/flake.lock index a488887..fa8d41e 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1699734195, - "narHash": "sha256-T7Q2ke4LJx16wos828YMqKnCCK3kxey0PdqH+LxVMV8=", + "lastModified": 1699781810, + "narHash": "sha256-LD+PIUbm1yQmQmGIbSsc/PB1dtJtGqXFgxRc1C7LlfQ=", "owner": "nix-community", "repo": "disko", - "rev": "89fd5b51f0725f9775ca9999d53a0a3e5d936490", + "rev": "2d7d77878c5d70f66f3d676ff66708d8d4f9d7df", "type": "github" }, "original": { @@ -31,11 +31,11 @@ ] }, "locked": { - "lastModified": 1699724244, - "narHash": "sha256-I3+cOlXU4jIoqnyYWezbNc26/56EI4YwwDQf80hdbeI=", + "lastModified": 1699812904, + "narHash": "sha256-+74SKAZrAFMytXfn0O1Sd5/bIl8OV+XxfjkXuGYqbYo=", "owner": "nix-community", "repo": "emacs-overlay", - "rev": "c5f0c468f8e92246473c1eabe997ad1c41fb6a1a", + "rev": "87219c6667c12e5f4442d27c073b9c56dbf0c95e", "type": "github" }, "original": { @@ -138,11 +138,11 @@ ] }, "locked": { - "lastModified": 1695108154, - "narHash": "sha256-gSg7UTVtls2yO9lKtP0yb66XBHT1Fx5qZSZbGMpSn2c=", + "lastModified": 1699748081, + "narHash": "sha256-MOmMapBydd7MTjhX4eeQZzKlCABWw8W6iSHSG4OeFKE=", "owner": "nix-community", "repo": "home-manager", - "rev": "07682fff75d41f18327a871088d20af2710d4744", + "rev": "04bac349d585c9df38d78e0285b780a140dc74a4", "type": "github" }, "original": { @@ -159,11 +159,11 @@ ] }, "locked": { - "lastModified": 1699156599, - "narHash": "sha256-Qk9ZE/pG9lNIGUVNArJxL0Hc0Soa92eQPPIhcDwWinU=", + "lastModified": 1699760693, + "narHash": "sha256-u/gkNUHQR/q23voqE5J4xmEWQIAqR+g3lUnCtzn0k7Y=", "owner": "Mic92", "repo": "nix-index-database", - "rev": "5388a4002179d6778d212dc2fdcc7ac3fdbd5b65", + "rev": "8aff4ca3dee60d1422489fe8d52c2f837b3ad113", "type": "github" }, "original": { @@ -179,11 +179,11 @@ ] }, "locked": { - "lastModified": 1698486730, - "narHash": "sha256-MP4bGb3JXkmmECssp0B7i0OipUXN7HurAqvfP830NLg=", + "lastModified": 1699785596, + "narHash": "sha256-njXqFmAEju1qZFePg6E3sca4xVp3P3T/Dm+D+be1fQM=", "owner": "Mic92", "repo": "nix-ld", - "rev": "846421112563fb6cf0334d9f124449aada964088", + "rev": "35ba5d7e8e6f838121a422e25ca38a40c41b8636", "type": "github" }, "original": { @@ -232,11 +232,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1699291058, - "narHash": "sha256-5ggduoaAMPHUy4riL+OrlAZE14Kh7JWX4oLEs22ZqfU=", + "lastModified": 1699596684, + "narHash": "sha256-XSXP8zjBZJBVvpNb2WmY0eW8O2ce+sVyj1T0/iBRIvg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "41de143fda10e33be0f47eab2bfe08a50f234267", + "rev": "da4024d0ead5d7820f6bd15147d3fe2a0c0cec73", "type": "github" }, "original": { @@ -264,11 +264,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1699343069, - "narHash": "sha256-s7BBhyLA6MI6FuJgs4F/SgpntHBzz40/qV0xLPW6A1Q=", + "lastModified": 1699725108, + "narHash": "sha256-NTiPW4jRC+9puakU4Vi8WpFEirhp92kTOSThuZke+FA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ec750fd01963ab6b20ee1f0cb488754e8036d89d", + "rev": "911ad1e67f458b6bcf0278fa85e33bb9924fed7e", "type": "github" }, "original": { @@ -296,11 +296,11 @@ }, "nur": { "locked": { - "lastModified": 1699730859, - "narHash": "sha256-B4NwfVftZRH9W53XJQ4BCPbAl3F/yyBJwn4qJLHAIIk=", + "lastModified": 1699837452, + "narHash": "sha256-aUg0+0MOPgDZtyDa4kcTLC7+zpnQWb5B3k9THN0uAOc=", "owner": "nix-community", "repo": "NUR", - "rev": "473af602cdfaf46f0a0d0b06e7678622f623f006", + "rev": "4cd37582b4d49983cf61ef3789f9dc58ff4a54f1", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 17477a4..8291dc3 100644 --- a/flake.nix +++ b/flake.nix @@ -1,14 +1,7 @@ { description = "flake for nixos-pulse"; - nixConfig = { - extra-trusted-substituters = [ - "https://nix-community.cachix.org" - ]; - extra-trusted-public-keys = [ - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - ]; - }; + nixConfig = { }; inputs = { nixpkgs-unstable = { @@ -125,39 +118,6 @@ nixos-pulse = import ./systems/nixos-pulse/disko.nix; nixos-desk = import ./systems/nixos-desk/disko.nix; }; - homeConfigurations = { - "tester@tristan-desk-arch" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - - modules = - [ - ./users/tester.nix - { - _module = { inherit args; }; - targets.genericLinux.enable = true; - programs = { - bash.enable = true; - zsh.enable = true; - home-manager.enable = true; - }; - } - ] - ++ hmModules; - }; - "tristand" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - - modules = - [ - ./users/tristand.nix - { - _module = { inherit args; }; - xsession.enable = true; - } - ] - ++ hmModules; - }; - }; nixosConfigurations = { nixos-pulse = nixpkgs.lib.nixosSystem { specialArgs = args; diff --git a/home-mods/shell/default.nix b/home-mods/shell/default.nix index 2b48a39..c62a6bf 100644 --- a/home-mods/shell/default.nix +++ b/home-mods/shell/default.nix @@ -15,6 +15,10 @@ let ref = "main"; rev = "c7392136bed264258c9b8788b14410e1ff06d602"; }; + myEmacs = (pkgs.emacsPackagesFor pkgs.emacs-pgtk).emacsWithPackages (epkgs: with epkgs; [ + vterm + treesit-grammars.with-all-grammars + ]); in { programs = { @@ -148,7 +152,7 @@ in emacs = { enable = true; defaultEditor = true; - package = lib.mkDefault pkgs.unstable-pkgs.emacs-pgtk; + package = myEmacs; }; }; @@ -176,7 +180,7 @@ in packages = with pkgs.unstable-pkgs; [ btop - config.services.emacs.package + myEmacs imagemagick rust-motd zellij @@ -211,6 +215,7 @@ in statix texlive.combined.scheme-full tokei + tree-sitter wget wl-clipboard zstd diff --git a/os-mods/cachix/caches/ai.nix b/os-mods/cachix/caches/ai.nix new file mode 100644 index 0000000..dfb41cb --- /dev/null +++ b/os-mods/cachix/caches/ai.nix @@ -0,0 +1,12 @@ +{ + nix = { + settings = { + substituters = [ + "https://ai.cachix.org" + ]; + trusted-public-keys = [ + "ai.cachix.org-1:N9dzRK+alWwoKXQlnn0H6aUx0lU/mspIoz8hMvGvbbc=" + ]; + }; + }; +} diff --git a/os-mods/cachix/caches/nix-community.nix b/os-mods/cachix/caches/nix-community.nix new file mode 100644 index 0000000..28de7e4 --- /dev/null +++ b/os-mods/cachix/caches/nix-community.nix @@ -0,0 +1,12 @@ +{ + nix = { + settings = { + substituters = [ + "https://nix-community.cachix.org" + ]; + trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + }; + }; +} diff --git a/os-mods/cachix/default.nix b/os-mods/cachix/default.nix new file mode 100644 index 0000000..82b23cd --- /dev/null +++ b/os-mods/cachix/default.nix @@ -0,0 +1,14 @@ +# WARN: this file will get overwritten by $ cachix use +{ pkgs, lib, ... }: + +let + folder = ./caches; + toImport = name: value: folder + ("/" + name); + filterCaches = key: value: value == "regular" && lib.hasSuffix ".nix" key; + imports = lib.mapAttrsToList toImport (lib.filterAttrs filterCaches (builtins.readDir folder)); +in +{ + inherit imports; + nix.settings.substituters = [ "https://cache.nixos.org/" ]; + nix.settings.trusted-users = [ "root" "tristand" ]; +} diff --git a/systems/nixos-desk/default.nix b/systems/nixos-desk/default.nix index c74c04e..7e1ba66 100644 --- a/systems/nixos-desk/default.nix +++ b/systems/nixos-desk/default.nix @@ -9,6 +9,7 @@ imports = [ (modulesPath + "/installer/scan/not-detected.nix") ../../os-mods/amdgpu + ../../os-mods/cachix ../../os-mods/common ../../os-mods/desktop ../../os-mods/network