From b566910da073278f17e589b56a376f098a275203 Mon Sep 17 00:00:00 2001 From: colin Date: Tue, 22 Nov 2022 05:28:41 +0000 Subject: [PATCH] home-manager: hide behind an enable flag --- hosts/common/default.nix | 1 + modules/home-manager/aerc.nix | 4 +++- modules/home-manager/default.nix | 6 +++++- modules/home-manager/discord.nix | 4 +++- modules/home-manager/firefox.nix | 2 +- modules/home-manager/git.nix | 4 +++- modules/home-manager/kitty.nix | 4 +++- modules/home-manager/mpv.nix | 4 +++- modules/home-manager/nb.nix | 5 ++++- modules/home-manager/neovim.nix | 4 +++- modules/home-manager/ssh.nix | 4 +++- modules/home-manager/sublime-music.nix | 4 +++- modules/home-manager/vlc.nix | 4 +++- modules/home-manager/zsh.nix | 4 +++- 14 files changed, 41 insertions(+), 13 deletions(-) diff --git a/hosts/common/default.nix b/hosts/common/default.nix index b2049a80..2907e2d2 100644 --- a/hosts/common/default.nix +++ b/hosts/common/default.nix @@ -11,6 +11,7 @@ ./vpn.nix ]; + sane.home-manager.enable = true; sane.nixcache.enable-trusted-keys = true; sane.packages.enableConsolePkgs = true; sane.packages.enableSystemPkgs = true; diff --git a/modules/home-manager/aerc.nix b/modules/home-manager/aerc.nix index 759d16c6..145807d5 100644 --- a/modules/home-manager/aerc.nix +++ b/modules/home-manager/aerc.nix @@ -1,5 +1,7 @@ # Terminal UI mail client -{ config, ... }: +{ config, lib, ... }: + +lib.mkIf config.sane.home-manager.enable { sops.secrets."aerc_accounts" = { owner = config.users.users.colin.name; diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index c12d3b74..452dd04d 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -33,6 +33,10 @@ in ]; options = { + sane.home-manager.enable = mkOption { + default = false; + type = types.bool; + }; # attributes to copy directly to home-manager's `wayland.windowManager` option sane.home-manager.windowManager = mkOption { default = {}; @@ -46,7 +50,7 @@ in }; }; - config = { + config = lib.mkIf cfg.enable { sane.impermanence.home-dirs = [ "archive" "dev" diff --git a/modules/home-manager/discord.nix b/modules/home-manager/discord.nix index f6cf34d9..c086d659 100644 --- a/modules/home-manager/discord.nix +++ b/modules/home-manager/discord.nix @@ -1,4 +1,6 @@ -{ ... }: +{ config, lib, ... }: + +lib.mkIf config.sane.home-manager.enable { # TODO: this should only be enabled on gui devices # make Discord usable even when client is "outdated" diff --git a/modules/home-manager/firefox.nix b/modules/home-manager/firefox.nix index f5b38590..9b8e37d5 100644 --- a/modules/home-manager/firefox.nix +++ b/modules/home-manager/firefox.nix @@ -102,7 +102,7 @@ in type = types.attrs; }; }; - config = { + config = lib.mkIf config.sane.home-manager.enable { # XXX: although home-manager calls this option `firefox`, we can use other browsers and it still mostly works. home-manager.users.colin = lib.mkIf (config.sane.gui.enable) { programs.firefox = { diff --git a/modules/home-manager/git.nix b/modules/home-manager/git.nix index 8f9ffb1b..b8822e1e 100644 --- a/modules/home-manager/git.nix +++ b/modules/home-manager/git.nix @@ -1,4 +1,6 @@ -{ pkgs, ... }: +{ config, lib, pkgs, ... }: + +lib.mkIf config.sane.home-manager.enable { home-manager.users.colin.programs.git = { enable = true; diff --git a/modules/home-manager/kitty.nix b/modules/home-manager/kitty.nix index aab88c78..35eced51 100644 --- a/modules/home-manager/kitty.nix +++ b/modules/home-manager/kitty.nix @@ -1,4 +1,6 @@ -{ ... }: +{ config, lib, ... }: + +lib.mkIf config.sane.home-manager.enable { home-manager.users.colin.programs.kitty = { enable = true; diff --git a/modules/home-manager/mpv.nix b/modules/home-manager/mpv.nix index 0549d737..add6dfb9 100644 --- a/modules/home-manager/mpv.nix +++ b/modules/home-manager/mpv.nix @@ -1,4 +1,6 @@ -{ ... }: +{ config, lib, ... }: + +lib.mkIf config.sane.home-manager.enable { home-manager.users.colin.programs.mpv = { enable = true; diff --git a/modules/home-manager/nb.nix b/modules/home-manager/nb.nix index a6e7b9c0..dde80248 100644 --- a/modules/home-manager/nb.nix +++ b/modules/home-manager/nb.nix @@ -8,7 +8,10 @@ # it offers a primitive web-server # and it offers some CLI query tools -{ lib, pkgs, ... }: lib.mkIf false # XXX disabled! +{ config, lib, pkgs, ... }: + +# lib.mkIf config.sane.home-manager.enable +lib.mkIf false # XXX disabled! { sane.packages.extraUserPkgs = [ pkgs.nb ]; diff --git a/modules/home-manager/neovim.nix b/modules/home-manager/neovim.nix index 78a589d1..ada23932 100644 --- a/modules/home-manager/neovim.nix +++ b/modules/home-manager/neovim.nix @@ -1,4 +1,6 @@ -{ pkgs, ... }: +{ config, lib, pkgs, ... }: + +lib.mkIf config.sane.home-manager.enable { sane.impermanence.home-dirs = [ ".cache/vim-swap" ]; diff --git a/modules/home-manager/ssh.nix b/modules/home-manager/ssh.nix index 60897833..4c9922a4 100644 --- a/modules/home-manager/ssh.nix +++ b/modules/home-manager/ssh.nix @@ -1,4 +1,6 @@ -{ config, pkgs, ... }: +{ config, lib, pkgs, ... }: + +lib.mkIf config.sane.home-manager.enable { home-manager.users.colin = let host = config.networking.hostName; diff --git a/modules/home-manager/sublime-music.nix b/modules/home-manager/sublime-music.nix index 3d7a718a..649fbdfd 100644 --- a/modules/home-manager/sublime-music.nix +++ b/modules/home-manager/sublime-music.nix @@ -1,4 +1,6 @@ -{ config, ... }: +{ config, lib, ... }: + +lib.mkIf config.sane.home-manager.enable { # TODO: this should only be shipped on gui platforms sops.secrets."sublime_music_config" = { diff --git a/modules/home-manager/vlc.nix b/modules/home-manager/vlc.nix index 9bb7d1fb..57f5b5af 100644 --- a/modules/home-manager/vlc.nix +++ b/modules/home-manager/vlc.nix @@ -1,4 +1,6 @@ -{ lib, ... }: +{ config, lib, ... }: + +lib.mkIf config.sane.home-manager.enable { home-manager.users.colin.xdg.configFile."vlc/vlcrc".text = let diff --git a/modules/home-manager/zsh.nix b/modules/home-manager/zsh.nix index eeba6bab..72ed4fac 100644 --- a/modules/home-manager/zsh.nix +++ b/modules/home-manager/zsh.nix @@ -1,4 +1,6 @@ -{ ... }: +{ config, lib, ... }: + +lib.mkIf config.sane.home-manager.enable { # we don't need to full zsh dir -- just the history file -- # but zsh will sometimes backup the history file and we get fewer errors if we do proper mounts instead of symlinks.