From 6e52ff7f3c33c39ab7acf2c4145977a46861e558 Mon Sep 17 00:00:00 2001 From: willemml Date: Thu, 29 Dec 2022 10:36:41 -0800 Subject: [PATCH] start using flakes --- emacs.nix | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 51 ++++++++++++++++++++++++ home.nix | 61 ++++++++++------------------- programs.nix | 4 +- 4 files changed, 181 insertions(+), 42 deletions(-) create mode 100644 emacs.nix create mode 100644 flake.nix diff --git a/emacs.nix b/emacs.nix new file mode 100644 index 0000000..812da40 --- /dev/null +++ b/emacs.nix @@ -0,0 +1,107 @@ +{ pkgs, isDarwin, homeDir, lib, config, inputs, nurNoPkgs, ... }: + +let + pcfg = config.programs.emacs.init.usePackage; +in { + imports = [ + pkgs.nur.repos.rycee.hmModules.emacs-init + pkgs.nur.repos.rycee.hmModules.emacs-notmuch + ]; + + programs.emacs.init = { + enable = true; + packageQuickstart = false; + recommendedGcSettings = true; + usePackageVerbose = false; + + earlyInit = '' +;; Disable Toolbar +(tool-bar-mode -1) +;; Disable scrollbar +(scroll-bar-mode -1) +;; Disable menubar +(menu-bar-mode -1) + +;; Increase garbage collector threshold before load +(setq gc-cons-threshold 640000000) + +(setq debug-on-error t) + +;; Use UTF-8 +(set-terminal-coding-system 'utf-8) +(set-keyboard-coding-system 'utf-8) +(prefer-coding-system 'utf-8) + +;; Minimize native-comp warnings +(setq native-comp-async-report-warnings-errors nil) +(setq warning-minimum-level 'error) +''; + prelude = '' +;; Disable startup message. +(setq inhibit-startup-screen t + inhibit-startup-echo-area-message (user-login-name)) + +(setq initial-major-mode 'fundamental-mode + initial-scratch-message nil) + +;; Accept 'y' and 'n' rather than 'yes' and 'no'. +(defalias 'yes-or-no-p 'y-or-n-p) + + +;; Don't use tabs for indents +(setq indent-tabs-mode nil) + +;; Don't warn when cannot guess python indent level +(setq python-indent-guess-indent-offset-verbose nil) + +;; Set indent level to 4 +(setq-default tab-width 4) + +;; Increase emacs data read limit (default too low for LSP) +(setq read-process-output-max (* 1024 1024)) + +;; Reduce wrist pain +(global-set-key (kbd "M-n") "~") +(global-set-key (kbd "M-N") "`") + +;; Stop creating backup and autosave files. +(setq make-backup-files nil + auto-save-default nil) + +;; Always show line and column number in the mode line. +(line-number-mode) +(column-number-mode) + +;; Use one space to end sentences. +(setq sentence-end-double-space nil) + +;; I typically want to use UTF-8. +(prefer-coding-system 'utf-8) + +;; Enable highlighting of current line. +(global-hl-line-mode 1) + +(setq custom-file (locate-user-emacs-file "custom.el")) +(load custom-file) + +;; When finding file in non-existing directory, offer to create the +;; parent directory. +(defun with-buffer-name-prompt-and-make-subdirs () + (let ((parent-directory (file-name-directory buffer-file-name))) + (when (and (not (file-exists-p parent-directory)) + (y-or-n-p (format "Directory `%s' does not exist! Create it? " parent-directory))) + (make-directory parent-directory t)))) + +(add-to-list 'find-file-not-found-functions #'with-buffer-name-prompt-and-make-subdirs) +''; + + usePackage = { + dracula-theme = { + enable = true; + config = '' +(load-theme 'dracula t) +''; + }; + }; + }; +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..21b3383 --- /dev/null +++ b/flake.nix @@ -0,0 +1,51 @@ +{ + description = "Willem's Home Manager configuration"; + + inputs = { + nixpkgs-22_11.url = "github:NixOS/nixpkgs/nixos-22.11"; + nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + nur.url = "github:nix-community/NUR"; + }; + + outputs = { self, nixpkgs-unstable, nixpkgs-22_11, home-manager, nur, ... }: + let + system = "aarch64-darwin"; + + pkgs = import nixpkgs-22_11 { + inherit system; + overlays = [ + (final: prev: { + nixpkgs-unstable = import nixpkgs-unstable { + inherit system; + overlays = [ ]; + }; + }) + ]; + }; + + nurNoPkgs = import nur { + nurpkgs = pkgs; + pkgs = throw "nixpkgs eval"; + }; + in { + homeConfigurations.willem = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + + # Specify your home configuration modules here, for example, + # the path to your home.nix. + modules = [ + ./home.nix + ]; + + # Optionally use extraSpecialArgs + # to pass through arguments to home.nix + extraSpecialArgs = { + inherit nurNoPkgs; + }; + }; + }; +} diff --git a/home.nix b/home.nix index e69dddd..59209b3 100644 --- a/home.nix +++ b/home.nix @@ -1,48 +1,29 @@ -{ pkgs, config, lib, ... }: +{ config, pkgs, lib, ... }: let inherit (lib.systems.elaborate { system = builtins.currentSystem; }) isLinux isDarwin; - user = builtins.getEnv "USER"; - homeDir = builtins.getEnv "HOME"; - unstableTarball = fetchTarball https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz; - nurTarball = fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz"; -in -rec { - nix = { - package = pkgs.nixUnstable; - extraOptions = '' - experimental-features = nix-command flakes - ''; - }; - + homeDirectory = config.home.homeDirectory; +in { nixpkgs.config = { allowUnfree = true; - packageOverrides = pkgs: { - unstable = import unstableTarball { - config = config.nixpkgs.config; - }; - nur = import nurTarball { - inherit pkgs; - config = config.nixpkgs.config; - }; - }; }; - - home = { - username = user; - homeDirectory = homeDir; - stateVersion = "22.11"; - packages = import ./packages.nix { inherit lib config pkgs isDarwin; }; + + programs = import ./programs.nix {inherit lib config pkgs isDarwin homeDirectory; }; + + home.packages = import ./packages.nix { inherit lib config pkgs isDarwin; }; + + home.language = { + base = "en_CA.UTF-8"; + messages = "en_US.UTF-8"; + ctype = "en_US.UTF-8"; }; - - programs = import ./programs.nix { inherit lib config pkgs isDarwin homeDir; }; - - home.file."${programs.gpg.homedir}/gpg-agent.conf" = { - source = pkgs.writeTextFile { - name = "gpg-agent-conf"; - text = '' - pinentry-program pinentry-mac - ''; - }; + + home.keyboard = { + layout = "us"; + variant = "colemak"; }; -} + + home.sessionVariables = { + EDITOR = "emacs"; + }; +} diff --git a/programs.nix b/programs.nix index 06115d2..33700b6 100644 --- a/programs.nix +++ b/programs.nix @@ -1,6 +1,8 @@ { lib, config, pkgs, isDarwin, homeDir, ... }: { + imports = [./emacs.nix]; + direnv = { enable = true; nix-direnv = { @@ -40,8 +42,6 @@ userEmail = "willem@leit.so"; }; - #emacs = import ./emacs.nix { inherit lib config pkgs isDarwin homeDir; }; - zoxide = { enable = true; enableZshIntegration = true;