Skip to content

Commit

Permalink
nix-darwin: add system module for nix-darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
ElvishJerricco authored and rycee committed Nov 19, 2018
1 parent f247b3b commit a9a4fb6
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
11 changes: 11 additions & 0 deletions modules/misc/news.nix
Expand Up @@ -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 changes: 41 additions & 0 deletions nix-darwin/default.nix
@@ -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);
};
}

0 comments on commit a9a4fb6

Please sign in to comment.