diff --git a/Makefile b/Makefile index bf15a8b2..2ad4dcdf 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/default.nix b/default.nix index a8eb183a..e7a788bd 100644 --- a/default.nix +++ b/default.nix @@ -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 diff --git a/hosts/default.nix b/hosts/default.nix index 1dfb4822..aad4d977 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -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"; } diff --git a/hosts/personal.nix b/hosts/personal.nix index 9713d787..71da1b9c 100644 --- a/hosts/personal.nix +++ b/hosts/personal.nix @@ -1,11 +1,8 @@ # hosts/personal.nix --- settings common to my personal systems -{ config, pkgs, ... }: +{ config, lib, pkgs, ... }: { - imports = [ - ./. - - ]; + 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 + ''; } diff --git a/modules/shell/zsh.nix b/modules/shell/zsh.nix index fae492d8..76750686 100644 --- a/modules/shell/zsh.nix +++ b/modules/shell/zsh.nix @@ -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" = { diff --git a/modules/xdg.nix b/modules/xdg.nix deleted file mode 100644 index 971bd5b0..00000000 --- a/modules/xdg.nix +++ /dev/null @@ -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 - ''; -} diff --git a/options.nix b/options.nix index 8413a75e..3d8ea379 100644 --- a/options.nix +++ b/options.nix @@ -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" ]; }