Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Home Manager support: profiles/suites, modules, extern, flake outputs #156

Merged
merged 5 commits into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
});
});

homeConfigurations = os.mkHomeConfigurations;

nixosModules =
let moduleList = import ./modules/module-list.nix;
in lib.pathsToImportedAttrs moduleList;
Expand Down Expand Up @@ -86,9 +88,6 @@
devShell = import ./shell {
inherit self system;
};

legacyPackages.hmActivationPackages =
os.mkHomeActivation;
}
);
in
Expand Down
2 changes: 1 addition & 1 deletion lib/devos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

devosSystem = dev.callLibs ./devosSystem.nix;

mkHomeActivation = dev.callLibs ./mkHomeActivation.nix;
mkHomeConfigurations = dev.callLibs ./mkHomeConfigurations.nix;

mkPackages = dev.callLibs ./mkPackages.nix;
}
Expand Down
19 changes: 19 additions & 0 deletions lib/devos/devosSystem.nix
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,29 @@ lib.nixosSystem (args // {
})
];
})).config;
hmConfig = (lib.nixosSystem
(args // {
modules = moduleList ++ [
({ config, ... }: {
home-manager.useUserPackages = lib.mkForce false;
home-manager.sharedModules = [
{
home.packages = config.environment.systemPackages;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hindsight review:

As it turns out, this may be a bit too aggressive. We may have to have a follow up PR to remove it, as it includes a lot of unrelated system packages and, worse, causes package conflicts in the community branch.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah thats fine we can remove that line. It worked for me and I didn't think it would cause any issues.

home.sessionVariables = {
inherit (config.environment.sessionVariables) NIX_PATH;
};
xdg.configFile."nix/registry.json".text =
config.environment.etc."nix/registry.json".text;
}
];
})
];
})).config;
in
moduleList ++ [{
system.build = {
iso = isoConfig.system.build.isoImage;
homes = hmConfig.home-manager.users;
};
}];
})
12 changes: 0 additions & 12 deletions lib/devos/mkHomeActivation.nix

This file was deleted.

12 changes: 12 additions & 0 deletions lib/devos/mkHomeConfigurations.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{ lib, self, ... }:

with lib;
let
mkHomes = host: config:
mapAttrs' (user: v: nameValuePair "${user}@${host}" v)
config.config.system.build.homes;

hmConfigs = mapAttrs mkHomes self.nixosConfigurations;

in
foldl recursiveUpdate {} (attrValues hmConfigs)
2 changes: 1 addition & 1 deletion shell/flk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ case "$1" in
;;

"home")
ref="$DEVSHELL_ROOT/#hmActivationPackages.$2.$3"
ref="$DEVSHELL_ROOT/#homeConfigurations.$3@$2.home.activationPackage"

if [[ "$4" == "switch" ]]; then
nix build "$ref" && result/activate &&
Expand Down
2 changes: 1 addition & 1 deletion users/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ flk home NixOS nixos switch
### Manually from outside the project:
```sh
# build
nix build "github:divnix/devos#hmActivationPackages.NixOS.nixos"
nix build "github:divnix/devos#homeConfigurations.nixos@NixOS.home.activationPackage"

# activate
./result/activate && unlink result
Expand Down