This is the other way to modularize, apparently
Reference: https://github.com/adisbladis/nixconfig
This commit is contained in:
parent
091e007628
commit
59fdb3111f
6 changed files with 107 additions and 4 deletions
|
|
@ -5,6 +5,9 @@
|
|||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
../modules/default.nix
|
||||
];
|
||||
nix.settings.experimental-features = "nix-command flakes";
|
||||
|
||||
# Bootloader.
|
||||
|
|
@ -71,10 +74,6 @@
|
|||
# Some programs need SUID wrappers, can be configured further or are
|
||||
# started in user sessions.
|
||||
# programs.mtr.enable = true;
|
||||
# programs.gnupg.agent = {
|
||||
# enable = true;
|
||||
# enableSSHSupport = true;
|
||||
# };
|
||||
|
||||
# List services that you want to enable:
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ in
|
|||
networking.hostName = "NixFrame"; # Define your hostname.
|
||||
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
|
||||
|
||||
my.bash-config.enable = true;
|
||||
|
||||
# Enable the X11 windowing system.
|
||||
services.xserver.enable = true;
|
||||
|
||||
|
|
|
|||
9
modules/bash-config/bashrc.sh
Normal file
9
modules/bash-config/bashrc.sh
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
[[ "$TERM" = "dumb" ]] && return
|
||||
|
||||
alias ls='ls --color=auto'
|
||||
|
||||
export EDITOR="emacsclient"
|
||||
|
||||
if [[ "$INSIDE_EMACS" = 'vterm' ]]; then
|
||||
source ~/.config/bash-config/emacs.sh
|
||||
fi
|
||||
11
modules/bash-config/default.nix
Normal file
11
modules/bash-config/default.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
cfg = config.my.bash-config;
|
||||
in
|
||||
{
|
||||
|
||||
options.my.bash-config.enable = lib.mkEnableOption "Enable bash configuration file";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
};
|
||||
}
|
||||
52
modules/bash-config/emacs.sh
Normal file
52
modules/bash-config/emacs.sh
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
# Some of the most useful features in emacs-libvterm require shell-side
|
||||
# configurations. The main goal of these additional functions is to enable the
|
||||
# shell to send information to `vterm` via properly escaped sequences. A
|
||||
# function that helps in this task, `vterm_printf`, is defined below.
|
||||
function vterm_printf(){
|
||||
if [ -n "$TMUX" ]; then
|
||||
# Tell tmux to pass the escape sequences through
|
||||
printf "\ePtmux;\e\e]%s\007\e\\" "$1"
|
||||
elif [ "${TERM%%-*}" = "screen" ]; then
|
||||
# GNU screen (screen, screen-256color, screen-256color-bce)
|
||||
printf "\eP\e]%s\007\e\\" "$1"
|
||||
else
|
||||
printf "\e]%s\e\\" "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
# Completely clear the buffer. With this, everything that is not on screen
|
||||
# is erased.
|
||||
function clear(){
|
||||
vterm_printf "51;Evterm-clear-scrollback";
|
||||
tput clear;
|
||||
}
|
||||
|
||||
# With vterm_cmd you can execute Emacs commands directly from the shell.
|
||||
# For example, vterm_cmd message "HI" will print "HI".
|
||||
# To enable new commands, you have to customize Emacs's variable
|
||||
# vterm-eval-cmds.
|
||||
vterm_cmd() {
|
||||
local vterm_elisp
|
||||
vterm_elisp=""
|
||||
while [ $# -gt 0 ]; do
|
||||
vterm_elisp="$vterm_elisp""$(printf '"%s" ' "$(printf "%s" "$1" | sed -e 's|\\|\\\\|g' -e 's|"|\\"|g')")"
|
||||
shift
|
||||
done
|
||||
vterm_printf "51;E$vterm_elisp"
|
||||
}
|
||||
|
||||
# This is to change the title of the buffer based on information provided by the
|
||||
# shell. See, http://tldp.org/HOWTO/Xterm-Title-4.html, for the meaning of the
|
||||
# various symbols.
|
||||
PROMPT_COMMAND='echo -ne "\033]0;${HOSTNAME}:${PWD}\007"'
|
||||
|
||||
# Sync directory and host in the shell with Emacs's current directory.
|
||||
# You may need to manually specify the hostname instead of $(hostname) in case
|
||||
# $(hostname) does not return the correct string to connect to the server.
|
||||
#
|
||||
# The escape sequence "51;A" has also the role of identifying the end of the
|
||||
# prompt
|
||||
vterm_prompt_end(){
|
||||
vterm_printf "51;A$(whoami)@$(hostname):$(pwd)"
|
||||
}
|
||||
PS1=$PS1'\[$(vterm_prompt_end)\]'
|
||||
30
modules/default.nix
Normal file
30
modules/default.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# What's the difference between lib and pkg?
|
||||
{ config, lib, ... }:
|
||||
|
||||
{
|
||||
# For each found file/folder, make it an absolute path by adding
|
||||
# "./." to the front.
|
||||
imports = map (x: ./. + "/${x}") (
|
||||
lib.attrNames (
|
||||
# Don't include default.nix, and files that don't end with
|
||||
# .nix. This means every subfolder MUST have a
|
||||
# default.nix.
|
||||
#
|
||||
# Perhaps, there's a way to do a tree traversal and grab ALL
|
||||
# .nix files?
|
||||
lib.filterAttrs
|
||||
(
|
||||
n: t: n != "default.nix" && (
|
||||
t == "directory" || lib.hasSuffix ".nix" n
|
||||
)
|
||||
)
|
||||
# Extract all files and folders in module directory. Returns
|
||||
# an attribute map with file name as key, and file type as
|
||||
# value.
|
||||
#
|
||||
# For some reason, the current directory is denoted as "./."
|
||||
# instead of "./". Why?
|
||||
(builtins.readDir ./.)
|
||||
)
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue