From a30af3f8370588b0e2b268851d1735ad6803e250 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 6 Apr 2020 01:57:44 -0400 Subject: [PATCH] User activation scripts instead of env extraInit --- hosts/kuro/default.nix | 1 - hosts/kuro/hardware-configuration.nix | 2 +- hosts/personal.nix | 4 +--- modules/default.nix | 11 +++-------- modules/desktop/apps/vm.nix | 3 ++- modules/shell/gnupg.nix | 3 ++- modules/shell/zsh.nix | 4 +--- 7 files changed, 10 insertions(+), 18 deletions(-) diff --git a/hosts/kuro/default.nix b/hosts/kuro/default.nix index 6266f841..f421325e 100644 --- a/hosts/kuro/default.nix +++ b/hosts/kuro/default.nix @@ -41,7 +41,6 @@ cc.enable = true; common-lisp.enable = true; rust.enable = true; - scala.enable = true; }; media = { diff --git a/hosts/kuro/hardware-configuration.nix b/hosts/kuro/hardware-configuration.nix index 142f5ebb..fd928d72 100644 --- a/hosts/kuro/hardware-configuration.nix +++ b/hosts/kuro/hardware-configuration.nix @@ -38,7 +38,7 @@ # For my intuos4 pro. Doesn't work for cintiqs. services.xserver.wacom.enable = true; # TODO Move this to udev - # my.init = '' + # system.userActivationScripts.wacom.text = '' # # lock tablet to main display # if xinput list --id-only "Wacom Intuos Pro S Pen stylus" 2>&1 >/dev/null; then # xinput map-to-output $(xinput list --id-only "Wacom Intuos Pro S Pen stylus") DVI-I-1 diff --git a/hosts/personal.nix b/hosts/personal.nix index b47edcc4..7475080f 100644 --- a/hosts/personal.nix +++ b/hosts/personal.nix @@ -49,9 +49,7 @@ 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? @@ -67,7 +65,7 @@ "${paConfigFile}/default.pa"; # Clean up leftovers, as much as we can - system.activationScripts.clearHome = '' + system.userActivationScripts.cleanupHome = '' pushd /home/${config.my.username} rm -rf .compose-cache .nv .pki .dbus .fehbg [ -s .xsession-errors ] || rm -f .xsession-errors* diff --git a/modules/default.nix b/modules/default.nix index 7bd7bb8f..f0938907 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -35,13 +35,6 @@ in { then concatMapStringsSep ":" (x: toString x) v else (toString v)); }; - init = mkOption { - type = types.lines; - description = '' - An init script that runs after the environment has been rebuilt or - booted. Anything done here should be idempotent and inexpensive. - ''; - }; alias = mkOption { type = with types; nullOr (attrsOf (nullOr (either str path))); @@ -78,8 +71,10 @@ in { environment.extraInit = let exportLines = mapAttrsToList (n: v: "export ${n}=\"${v}\"") config.my.env; in '' + export XAUTHORITY=/tmp/Xauthority + [ -e ~/.Xauthority ] && mv -f ~/.Xauthority "$XAUTHORITY" + ${concatStringsSep "\n" exportLines} - ${config.my.init} ''; # I avoid programs.zsh.*Init variables because they initialize too soon. My diff --git a/modules/desktop/apps/vm.nix b/modules/desktop/apps/vm.nix index ef4a821c..a4d3ab77 100644 --- a/modules/desktop/apps/vm.nix +++ b/modules/desktop/apps/vm.nix @@ -17,7 +17,8 @@ with lib; config = mkIf config.modules.desktop.apps.vm.enable { virtualisation.virtualbox.host = { enable = true; - enableExtensionPack = true; # urg, takes so long to build + # urg, takes so long to build, but needed for macOS guest + enableExtensionPack = true; }; my.user.extraGroups = [ "vboxusers" ]; diff --git a/modules/shell/gnupg.nix b/modules/shell/gnupg.nix index 96f0d025..401d2f4a 100644 --- a/modules/shell/gnupg.nix +++ b/modules/shell/gnupg.nix @@ -16,9 +16,10 @@ in { pinentry ]; env.GNUPGHOME = "$XDG_CONFIG_HOME/gnupg"; - init = "mkdir -p \"$GNUPGHOME\" -m 700"; }; + system.activationScripts.setupGnuPG = "mkdir -p \"${config.my.env.GNUPGHOME}\" -m 700"; + programs.gnupg.agent = { enable = true; enableSSHSupport = true; diff --git a/modules/shell/zsh.nix b/modules/shell/zsh.nix index 78449a3d..2961d8ca 100644 --- a/modules/shell/zsh.nix +++ b/modules/shell/zsh.nix @@ -51,8 +51,6 @@ with lib; promptInit = ""; }; - system.userActivationScripts.cleanupZgen = '' - rm -fv $XDG_CACHE_HOME/zsh/* - ''; + system.userActivationScripts.cleanupZgen = "rm -fv $XDG_CACHE_HOME/zsh/*"; }; }