nix-darwin: add system module for nix-darwin

This commit is contained in:
Will Fancher 2018-04-03 00:53:08 -04:00 committed by Robert Helgesson
parent f247b3b99b
commit a9a4fb641f
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
2 changed files with 52 additions and 0 deletions

View file

@ -830,6 +830,17 @@ in
A new module is available: 'programs.afew'.
'';
}
{
time = "2018-11-19T00:40:34+00:00";
message = ''
A new nix-darwin module is available. Use it the same way the NixOS
module is used. A major limitation is that Home Manager services don't
work, as they depend explicitly on Linux and systemd user services.
However, 'home.file' and 'home.packages' do work. Everything else is
untested at this time.
'';
}
];
};
}

41
nix-darwin/default.nix Normal file
View file

@ -0,0 +1,41 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.home-manager;
hmModule = types.submodule ({name, ...}: {
imports = import ../modules/modules.nix {
inherit lib pkgs;
nixosSubmodule = true;
};
config = {
home.username = config.users.users.${name}.name;
home.homeDirectory = config.users.users.${name}.home;
};
});
in
{
options = {
home-manager.users = mkOption {
type = types.attrsOf hmModule;
default = {};
description = ''
Per-user Home Manager configuration.
'';
};
};
config = mkIf (cfg.users != {}) {
system.activationScripts.extraActivation.text =
lib.concatStringsSep "\n" (lib.mapAttrsToList (username: usercfg: ''
echo Activating home-manager configuration for ${username}
sudo -u ${username} ${usercfg.home.activationPackage}/activate
'') cfg.users);
};
}