From cb57ae369c88a2c731bddf2ee100ed68c88498a4 Mon Sep 17 00:00:00 2001 From: Marcel Kapfer Date: Tue, 11 Jul 2023 22:44:03 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20(Nix)=20Add=20Nix=20home-manager=20?= =?UTF-8?q?configuration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nix-stow.sh | 38 ++++ .../.config/home-manager/common.nix | 171 ++++++++++++++++++ 2 files changed, 209 insertions(+) create mode 100755 nix-stow.sh create mode 100644 nix/home-manager/.config/home-manager/common.nix diff --git a/nix-stow.sh b/nix-stow.sh new file mode 100755 index 0000000..c4b1829 --- /dev/null +++ b/nix-stow.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -euo pipefail + +PRIMARY="\033[0;35m" +LOG="\033[0;36m" +SUCCESS="\033[0;32m" +NC="\033[0m" +BRAND="[nix-stow]" + +function log { + echo -e "${PRIMARY}${BRAND} ${LOG}$1${NC}" +} + +function success { + echo -e "${PRIMARY}${BRAND} ${SUCCESS}$1${NC}" +} + +NIX_DOTFILES="${NIX_DOTFILES:=$(pwd)/nix}" +NIX_WORK_DOTFILES="${NIX_WORK_DOTFILES:=$(pwd)/dot-work/nix}" +NIX_PRIVATE_DOTFILES="${NIX_PRIVATE_DOTFILES:=$(pwd)/dot-private/nix}" + +WORK_MACHINE="knuth" +CURRENT_MACHINE="$(hostname)" + +log "Stowing common home-manager config." +stow $@ -d "$NIX_DOTFILES" -t "$HOME" home-manager + +if [[ "$WORK_MACHINE" == "$CURRENT_MACHINE" ]] +then + log "Detected work system. Stowing work-specific home-manager config." + stow $@ -d "$NIX_WORK_DOTFILES" -t "$HOME" home-manager +else + log "Detected personal system. Stowing private home-manager config." + stow $@ -d "$NIX_PRIVATE_DOTFILES" -t "$HOME" home-manager +fi + +success "Finished stowing Nix files." diff --git a/nix/home-manager/.config/home-manager/common.nix b/nix/home-manager/.config/home-manager/common.nix new file mode 100644 index 0000000..88a5c3a --- /dev/null +++ b/nix/home-manager/.config/home-manager/common.nix @@ -0,0 +1,171 @@ +{ config, pkgs, ...}: + +{ + # This value determines the Home Manager release that your configuration is + # compatible with. This helps avoid breakage when a new Home Manager release + # introduces backwards incompatible changes. + # + # You should not change this value, even if you update Home Manager. If you do + # want to update the value, then make sure to first check the Home Manager + # release notes. + home.stateVersion = "23.05"; # Please read the comment before changing. + + # The home.packages option allows you to install Nix packages into your + # environment. + home.packages = with pkgs; [ + colordiff + firefox + jetbrains-mono + keepassxc + rlwrap + open-sans + + # # It is sometimes useful to fine-tune packages, for example, by applying + # # overrides. You can do that directly here, just don't forget the + # # parentheses. Maybe you want to install Nerd Fonts with a limited number of + # # fonts? + # (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; }) + + # # You can also create simple shell scripts directly inside your + # # configuration. For example, this adds a command 'my-hello' to your + # # environment: + # (pkgs.writeShellScriptBin "my-hello" '' + # echo "Hello, ${config.home.username}!" + # '') + ]; + + # Home Manager is pretty good at managing dotfiles. The primary way to manage + # plain files is through 'home.file'. + home.file = { + ".config/nvim/init.vim".source = ~/.dotfiles/neovim/.config/nvim/init.vim; + + # # You can also set the file content immediately. + # ".gradle/gradle.properties".text = '' + # org.gradle.console=verbose + # org.gradle.daemon.idletimeout=3600000 + # ''; + }; + + home.sessionVariables = { + # EDITOR = "emacs"; + # VISUAL = "emacs"; + }; + + accounts.email.maildirBasePath = ".mbsync"; + + ############ + # PROGRAMS # + ############ + + programs.emacs = { + enable = true; + extraPackages = epkgs: [ + epkgs.nix-mode + epkgs.vterm + ]; + }; + + programs.exa = { + enable = true; + enableAliases = true; + git = true; + }; + + programs.fish = { + enable = true; + + shellAbbrs = { + ping = "ping -c 3"; + pingtest = "ping -c 3 mmk2410.org"; + g = "git"; + s = "sudo"; + }; + + shellAliases = { + df = "df -h"; + du = "du -c -h"; + mkdir = "mkdir -p -v"; + ln = "ln -i"; + chown = "chown --preserve-root"; + chmod = "chmod --preserve-root"; + chgrp = "chgrp --preserve-root"; + ps = "ps aux k%cpu"; + o = "xdg-open"; + diff = "colordiff"; + sbcl = "rlwrap sbcl"; + "..." = "cd ../.."; + }; + + plugins = [ + { name = "z"; src = pkgs.fishPlugins.z.src; } + { name = "hydro"; src = pkgs.fishPlugins.hydro.src; } + { name = "foreign-env"; src = pkgs.fishPlugins.foreign-env.src; } + { + name = "emacs-vterm"; + src = ~/.dotfiles/fish/.config/fish/plugins/emacs-vterm; + } + ]; + + interactiveShellInit = '' + for f in ${pkgs.fishPlugins.hydro.src}/functions/*.fish + source $f + end + ''; + }; + + programs.fzf = { + enable = true; + enableFishIntegration = true; + }; + + programs.git = { + enable = true; + lfs.enable = true; + userName = "Marcel Kapfer"; + extraConfig.init.defaultBranch = "main"; + }; + + programs.gpg.enable = true; + + programs.htop.enable = true; + + programs.mbsync = { + enable = true; + extraConfig = "CopyArrivalDate yes\n\n"; + }; + + programs.msmtp.enable = true; + + programs.mu.enable = true; + + programs.neovim = { + enable = true; + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + }; + + programs.ssh.enable = true; + + services.emacs = { + enable = true; + client.enable = true; + defaultEditor = true; + }; + + services.gpg-agent = { + enable = true; + enableFishIntegration = true; + defaultCacheTtl = 14400; + maxCacheTtl = 14400; + pinentryFlavor = "gnome3"; + }; + + services.mbsync = { + enable = true; + postExec = "${pkgs.emacs}/bin/emacsclient -equ '(mu4e-update-index)'"; + }; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; +}