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 c012f2f commit 4e06a53
Show file tree
Hide file tree
Showing 6 changed files with 37 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 = {
};
}
4 changes: 4 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
let moduleList = import ./modules/module-list.nix;
in lib.pathsToImportedAttrs moduleList;

homeModules =
let moduleList = import ./users/modules/module-list.nix;
in lib.pathsToImportedAttrs moduleList;

overlay = import ./pkgs;
overlays = lib.pathsToImportedAttrs (lib.pathsIn ./overlays);

Expand Down
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 ++ (builtins.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 = lib.mapAttrs (_: v: dev.os.profileMap v) suites // {
inherit allProfiles allUsers;
};
user = lib.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 4e06a53

Please sign in to comment.