From a9a4fb641feb89da9f9d9140b5299cbb4c433d29 Mon Sep 17 00:00:00 2001 From: Will Fancher Date: Tue, 3 Apr 2018 00:53:08 -0400 Subject: [PATCH] nix-darwin: add system module for nix-darwin --- modules/misc/news.nix | 11 +++++++++++ nix-darwin/default.nix | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 nix-darwin/default.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index e7d7f27d7..21529f46d 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -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. + ''; + } ]; }; } diff --git a/nix-darwin/default.nix b/nix-darwin/default.nix new file mode 100644 index 000000000..c2ec350cb --- /dev/null +++ b/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); + }; +}