Compare commits

...

4 commits

4 changed files with 57 additions and 20 deletions

20
cerulean/home/default.nix Normal file
View file

@ -0,0 +1,20 @@
# NOTE: you can access the system configuration via the `osConfig` arg
{
username,
lib,
...
}: {
# WARNING: required for home-manager to work
programs.home-manager.enable = true; # user must apply lib.mkForce
# Nicely reload systemd units when changing configs
systemd.user.startServices = lib.mkDefault "sd-switch";
home = {
username = lib.mkDefault username;
homeDirectory = lib.mkDefault "/home/${username}";
sessionVariables = {
NIX_SHELL_PRESERVE_PROMPT = lib.mkDefault 1;
};
};
}

View file

@ -12,18 +12,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.
{
root,
config,
lib,
_cerulean,
config,
root,
lib,
...
} @ args: let
inherit
(builtins)
attrNames
filter
pathExists
;
inherit
(lib)
filterAttrs
mapAttrs
;
in {
imports = [
_cerulean.homeManager.nixosModules.default
@ -49,18 +53,27 @@ in {
config = {
home-manager = {
useUserPackages = lib.mkDefault false;
useGlobalPkgs = lib.mkDefault true;
overwriteBackup = lib.mkDefault false;
backupFileExtension = lib.mkDefault "bak";
users =
config.users.users
|> attrNames
|> filter (x: pathExists (root + "/homes/${x}"))
|> (x:
lib.genAttrs x (y:
import (root + "/homes/${y}")));
|> filterAttrs (name: value: value.manageHome && pathExists /${root}/homes/${name})
|> mapAttrs (name: _: {...}: {
imports = [/${root}/homes/${name}];
# per-user arguments
_module.args.username = name;
});
extraSpecialArgs = _cerulean.specialArgs;
sharedModules = [
# user configuration
(import (root + "/nixpkgs.nix"))
../home
(import /${root}/nixpkgs.nix)
# options declarations
(import ./nixpkgs.nix (args // {contextName = "homes";}))
];

View file

@ -73,19 +73,23 @@ in {
_module.args = removeAttrs repos ["pkgs" "base"];
nixpkgs = let
nixpkgConfig = {
nixpkgsConfig = {
config = lib.mkForce (basePkgs.config or {});
overlays = lib.mkForce (basePkgs.overlays or []);
};
in
if contextName == "hosts"
then
nixpkgConfig
nixpkgsHostsConfig =
nixpkgsConfig
// {
flake.source = lib.mkForce base;
}
};
nixpkgsHomesConfig = lib.mkIf (!config.home-manager.useGlobalPkgs) nixpkgsConfig;
in
if contextName == "hosts"
then nixpkgsHostsConfig
else if contextName == "homes"
then nixpkgConfig
then nixpkgsHomesConfig
else {};
};
}

View file

@ -65,7 +65,7 @@
# flatten recursion result
|> concatLists
# find import location
|> map (group: nt.findImport (/${root}/groups/${group._name})
|> map (group: nt.findImport /${root}/groups/${group._name})
# filter by uniqueness
|> nt.prim.unique
# ignore missing groups