Skip to content

Commit

Permalink
improve home Manager support: profiles/suites, modules, extern, flake…
Browse files Browse the repository at this point in the history
… outputs
  • Loading branch information
Pacman99 committed Mar 14, 2021
1 parent c6bf833 commit 313d5a2
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 12 deletions.
13 changes: 8 additions & 5 deletions extern/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{ inputs }: with inputs;
let
hmModules = { };
in
{
modules = [
home.nixosModules.home-manager
Expand All @@ -18,9 +15,15 @@ in

# passed to all nixos modules
specialArgs = {
inherit hmModules;

overrideModulesPath = "${override}/nixos/modules";
hardware = nixos-hardware.nixosModules;
};

# added to home-manager
userModules = [
];

# passed to all home-manager modules
userSpecialArgs = {
};
}
11 changes: 8 additions & 3 deletions hosts/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ let
};

global = {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;

extraSpecialArgs = extern.userSpecialArgs // { suites = suites.user; };
sharedModules = extern.userModules ++ (attrValues self.homeModules);
};

hardware.enableRedistributableFirmware = lib.mkDefault true;

Expand Down Expand Up @@ -62,7 +67,7 @@ let
modOverrides
] ++ extern.modules;

specialArgs = extern.specialArgs // { inherit suites; };
specialArgs = extern.specialArgs // { suites = suites.system; };

mkHostConfig = hostName:
let
Expand Down
16 changes: 14 additions & 2 deletions suites/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ let
inherit (lib) dev;

profiles = dev.os.mkProfileAttrs (toString ../profiles);
userProfiles = dev.os.mkProfileAttrs (toString ../users/profiles);
users = dev.os.mkProfileAttrs (toString ../users);

allProfiles =
Expand All @@ -17,7 +18,18 @@ let
suites = with profiles; rec {
base = [ users.nixos users.root ];
};

# available as 'suites' within the home-manager configuration
userSuites = with userProfiles; rec {
base = [ direnv git ];
};

in
lib.mapAttrs (_: v: dev.os.profileMap v) suites // {
inherit allProfiles allUsers;
{
system = mapAttrs (_: v: dev.os.profileMap v) suites // {
inherit allProfiles allUsers;
};
user = mapAttrs (_: v: dev.os.profileMap v) userSuites // {
allProfiles = userProfiles;
};
}
1 change: 1 addition & 0 deletions users/modules/module-list.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
4 changes: 2 additions & 2 deletions users/nixos/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ ... }:
{
home-manager.users.nixos = {
imports = [ ../profiles/git ../profiles/direnv ];
home-manager.users.nixos = { suites, ... }: {
imports = suites.base;
};

users.users.nixos = {
Expand Down

0 comments on commit 313d5a2

Please sign in to comment.