start using flakes

This commit is contained in:
willemml 2022-12-29 10:36:41 -08:00
parent 2814044d9f
commit 6e52ff7f3c
Signed by: willemml
GPG key ID: C3DE5DF6198DACBD
4 changed files with 181 additions and 42 deletions

107
emacs.nix Normal file
View file

@ -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)
'';
};
};
};
}

51
flake.nix Normal file
View file

@ -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;
};
};
};
}

View file

@ -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";
};
}

View file

@ -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;