Refactor ~again~

Who needs free time? I don't.
This commit is contained in:
Henrik Lissner 2020-01-17 16:13:14 -05:00
parent bbe5d55143
commit e96548382c
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
7 changed files with 61 additions and 70 deletions

View file

@ -1,9 +1,7 @@
NIXOS_VERSION := 19.09
NIXOS_PREFIX := $(PREFIX)/etc/nixos
COMMAND := test
FLAGS := -I "nixpkgs-overlays=$$(pwd)/overlays.nix" \
-I "config=$$(pwd)/config" \
-I "modules=$$(pwd)/modules" $(FLAGS)
FLAGS := -I "config=$$(pwd)/config" -I "modules=$$(pwd)/modules" $(FLAGS)
# The real Labowski
all: channels

View file

@ -16,9 +16,6 @@ device:
# So we can use absolute import paths
"config=/etc/dotfiles/config"
"modules=/etc/dotfiles/modules"
# We define nixpkgs-overlays so our overlays will be available to
# nix-shell/nix-build outside of rebuilding...
"nixpkgs-overlays=/etc/dotfiles/overlays.nix"
];
# ...but we still need to set nixpkgs.overlays to make them visible to the
# rebuild process, however...
@ -27,6 +24,13 @@ device:
# For instant nix-shell scripts
environment.systemPackages = [ pkgs.my.cached-nix-shell ];
environment.shellAliases = {
nix-env = "NIXPKGS_ALLOW_UNFREE=1 nix-env";
nix-shell = ''NIX_PATH="nixpkgs-overlays=/etc/dotfiles/overlays.nix:$NIX_PATH" nix-shell'';
nsh = "nix-shell";
nen = "nix-env";
dots = "make -C ~/.dotfiles";
};
# This value determines the NixOS release with which your system is to be
# compatible, in order to avoid breaking some software such as database

View file

@ -16,17 +16,10 @@
### My user settings
my.username = "hlissner";
my.env.PATH = [ ../bin ];
my.user = {
isNormalUser = true;
uid = 1000;
extraGroups = [ "wheel" "video" "networkmanager" ];
shell = pkgs.zsh;
};
my.alias.nix-env = "NIXPKGS_ALLOW_UNFREE=1 nix-env";
my.alias.nsh = "nix-shell";
my.alias.nen = "nix-env";
my.alias.sc = "systemctl";
my.alias.ssc = "sudo systemctl";
my.alias.dots = "make -C ~/.dotfiles";
}

View file

@ -1,11 +1,8 @@
# hosts/personal.nix --- settings common to my personal systems
{ config, pkgs, ... }:
{ config, lib, pkgs, ... }:
{
imports = [
./.
<modules/xdg.nix>
];
imports = [ ./. ];
# Support for more filesystems
environment.systemPackages = with pkgs; [
@ -29,4 +26,51 @@
"192.168.1.11" = [ "shiro" ];
"192.168.1.12" = [ "midori" ];
};
### A tidy $HOME is a tidy mind
# Obey XDG conventions;
my.home.xdg.enable = true;
environment.variables = {
# These are the defaults, but some applications are buggy when these lack
# explicit values.
XDG_CONFIG_HOME = "$HOME/.config";
XDG_CACHE_HOME = "$HOME/.cache";
XDG_DATA_HOME = "$HOME/.local/share";
XDG_BIN_HOME = "$HOME/.local/bin";
};
# Conform more programs to XDG conventions. The rest are handled by their
# respective modules.
my.env = {
__GL_SHADER_DISK_CACHE_PATH = "$XDG_CACHE_HOME/nv";
CUDA_CACHE_PATH = "$XDG_CACHE_HOME/nv";
HISTFILE = "$XDG_DATA_HOME/bash/history";
INPUTRC = "$XDG_CACHE_HOME/readline/inputrc";
LESSHISTFILE = "$XDG_CACHE_HOME/lesshst";
WGETRC = "$XDG_CACHE_HOME/wgetrc";
XAUTHORITY = "/tmp/Xauthority";
};
my.init = "[ -e ~/.Xauthority ] && mv -f ~/.Xauthority \"$XAUTHORITY\"";
# Prevents ~/.esd_auth files by disabling the esound protocol module for
# pulseaudio, which I likely don't need. Is there a better way?
hardware.pulseaudio.configFile =
let paConfigFile =
with pkgs; runCommand "disablePulseaudioEsoundModule"
{ buildInputs = [ pulseaudio ]; } ''
mkdir "$out"
cp ${pulseaudio}/etc/pulse/default.pa "$out/default.pa"
sed -i -e 's|load-module module-esound-protocol-unix|# ...|' "$out/default.pa"
'';
in lib.mkIf config.hardware.pulseaudio.enable
"${paConfigFile}/default.pa";
# Clean up leftovers, as much as we can
system.activationScripts.clearHome = ''
pushd /home/${config.my.username}
rm -rf .compose-cache .nv .pki .dbus .fehbg
[ -s .xsession-errors ] || rm -f .xsession-errors*
popd
'';
}

View file

@ -22,6 +22,8 @@
alias.l = "exa -1";
alias.ll = "exa -l";
alias.la = "LC_COLLATE=C exa -la";
alias.sc = "systemctl";
alias.ssc = "sudo systemctl";
# Write it recursively so other modules can write files to it
home.xdg.configFile."zsh" = {

View file

@ -1,49 +0,0 @@
# modules/xdg.nix -- a tidy $HOME is a tidy mind
{ config, lib, pkgs, ... }:
{
# Obey XDG conventions;
my.home.xdg.enable = true;
environment.variables = {
# These are the defaults, but some applications are buggy when these lack
# explicit values.
XDG_CONFIG_HOME = "$HOME/.config";
XDG_CACHE_HOME = "$HOME/.cache";
XDG_DATA_HOME = "$HOME/.local/share";
XDG_BIN_HOME = "$HOME/.local/bin";
};
# Conform more programs to XDG conventions. The rest are handled by their
# respective modules.
my.env = {
__GL_SHADER_DISK_CACHE_PATH = "$XDG_CACHE_HOME/nv";
CUDA_CACHE_PATH = "$XDG_CACHE_HOME/nv";
HISTFILE = "$XDG_DATA_HOME/bash/history";
INPUTRC = "$XDG_CACHE_HOME/readline/inputrc";
LESSHISTFILE = "$XDG_CACHE_HOME/lesshst";
WGETRC = "$XDG_CACHE_HOME/wgetrc";
XAUTHORITY = "/tmp/Xauthority";
};
my.init = "[ -e ~/.Xauthority ] && mv -f ~/.Xauthority \"$XAUTHORITY\"";
# Prevents ~/.esd_auth files by disabling the esound protocol module for
# pulseaudio, which I likely don't need. Is there a better way?
hardware.pulseaudio.configFile =
let paConfigFile =
with pkgs; runCommand "disablePulseaudioEsoundModule"
{ buildInputs = [ pulseaudio ]; } ''
mkdir "$out"
cp ${pulseaudio}/etc/pulse/default.pa "$out/default.pa"
sed -i -e 's|load-module module-esound-protocol-unix|# ...|' "$out/default.pa"
'';
in lib.mkIf config.hardware.pulseaudio.enable
"${paConfigFile}/default.pa";
# Clean up leftovers, as much as we can
system.activationScripts.clearHome = ''
pushd /home/${config.my.username}
rm -rf .compose-cache .nv .pki .dbus .fehbg
[ -s .xsession-errors ] || rm -f .xsession-errors*
popd
'';
}

View file

@ -43,6 +43,8 @@ in
booted. Anything done here should be idempotent and inexpensive.
'';
};
## PATH should always start with its old value
config.my.env.PATH = [ ./bin "$PATH" ];
config.environment.extraInit =
let exportLines = mapAttrsToList (n: v: "export ${n}=\"${v}\"") config.my.env;
in ''
@ -84,7 +86,4 @@ in
# This file is autogenerated, do not edit it!
${config.my.zsh.env};
'';
## PATH should always start with its old value
config.my.env.PATH = [ "$PATH" ];
}