From 7a382368e80e0097823050d0b40a88484b9e921f Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 25 Jun 2021 20:43:19 +0200 Subject: [PATCH] modules: move home configuration from flake --- flake.nix | 7 ------- modules/default.nix | 4 ++++ modules/home.nix | 19 ++++++++++++++++--- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/flake.nix b/flake.nix index 4f0460f..2b0052a 100644 --- a/flake.nix +++ b/flake.nix @@ -70,13 +70,6 @@ nur.overlay ]; } - home-manager.nixosModules.home-manager - ({ config, ... }: { - home-manager.users.${config.my.user.name} = import ./home; - # Nix Flakes compatibility - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - }) # Include generic settings ./modules # Include bundles of settings diff --git a/modules/default.nix b/modules/default.nix index 061da01..798fb0d 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -17,6 +17,10 @@ example = "alice"; description = "my username"; }; + + home = { + enable = my.mkDisableOption "home-manager configuration"; + }; }; }; } diff --git a/modules/home.nix b/modules/home.nix index be0aedf..8ae1b3e 100644 --- a/modules/home.nix +++ b/modules/home.nix @@ -1,11 +1,24 @@ -# Simplify setting home options -{ config, lib, ... }: +{ config, inputs, lib, ... }: let actualPath = [ "home-manager" "users" config.my.user.name "my" "home" ]; aliasPath = [ "my" "home" ]; + + cfg = config.my.user.home; in { imports = [ - (lib.mkAliasOptionModule aliasPath actualPath) + inputs.home-manager.nixosModule # enable home-manager options + (lib.mkAliasOptionModule aliasPath actualPath) # simplify setting home options ]; + + config = lib.mkIf cfg.enable { + home-manager = { + # Not a fan of out-of-directory imports, but this is a good exception + users.${config.my.user.name} = import ../home; + + # Nix Flakes compatibility + useGlobalPkgs = true; + useUserPackages = true; + }; + }; }