2016-10-18 21:14:18 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.system;
|
|
|
|
|
2016-11-05 21:47:09 +00:00
|
|
|
in
|
2016-11-01 20:25:22 +00:00
|
|
|
|
2016-11-05 21:47:09 +00:00
|
|
|
{
|
2016-10-18 21:14:18 +00:00
|
|
|
options = {
|
|
|
|
|
|
|
|
system.build = mkOption {
|
|
|
|
internal = true;
|
|
|
|
default = {};
|
|
|
|
description = ''
|
|
|
|
Attribute set of derivation used to setup the system.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2016-10-19 18:03:17 +00:00
|
|
|
system.path = mkOption {
|
2016-10-18 21:14:18 +00:00
|
|
|
internal = true;
|
2016-10-19 18:03:17 +00:00
|
|
|
type = types.package;
|
|
|
|
description = ''
|
|
|
|
The packages you want in the system environment.
|
|
|
|
'';
|
2016-10-18 21:14:18 +00:00
|
|
|
};
|
|
|
|
|
2016-10-29 20:40:55 +00:00
|
|
|
system.nixdarwinLabel = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "16.09";
|
|
|
|
};
|
|
|
|
|
2016-10-18 21:14:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
|
2016-10-29 20:40:55 +00:00
|
|
|
system.build.toplevel = pkgs.stdenvNoCC.mkDerivation {
|
|
|
|
name = "nixdarwin-system-${cfg.nixdarwinLabel}";
|
|
|
|
preferLocalBuild = true;
|
|
|
|
|
2016-11-01 20:25:22 +00:00
|
|
|
activationScript = cfg.activationScripts.script.text;
|
2016-10-29 20:40:55 +00:00
|
|
|
inherit (cfg) nixdarwinLabel;
|
|
|
|
|
|
|
|
buildCommand = ''
|
|
|
|
mkdir $out
|
|
|
|
|
|
|
|
ln -s ${cfg.build.etc}/etc $out/etc
|
|
|
|
ln -s ${cfg.path} $out/sw
|
|
|
|
|
2016-11-07 20:00:23 +00:00
|
|
|
mkdir -p $out/Library
|
|
|
|
ln -s ${cfg.build.launchd}/Library/LaunchDaemons $out/Library/LaunchDaemons
|
|
|
|
|
2016-10-29 20:40:55 +00:00
|
|
|
echo "$activationScript" > $out/activate
|
|
|
|
substituteInPlace $out/activate --subst-var out
|
|
|
|
chmod u+x $out/activate
|
|
|
|
unset activationScript
|
|
|
|
|
|
|
|
echo -n "$nixdarwinLabel" > $out/nixdarwin-version
|
|
|
|
echo -n "$system" > $out/system
|
|
|
|
'';
|
2016-10-18 21:14:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|