2016-10-18 21:14:18 +00:00
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
2016-12-07 22:06:18 +00:00
|
|
|
|
inherit (pkgs) stdenvNoCC;
|
|
|
|
|
|
2016-10-18 21:14:18 +00:00
|
|
|
|
cfg = config.system;
|
|
|
|
|
|
2017-05-11 19:21:39 +00:00
|
|
|
|
failedAssertions = map (x: x.message) (filter (x: !x.assertion) config.assertions);
|
2017-01-08 12:11:02 +00:00
|
|
|
|
|
|
|
|
|
throwAssertions = res: if (failedAssertions != []) then throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: "- ${x}") failedAssertions)}" else res;
|
|
|
|
|
showWarnings = res: fold (w: x: builtins.trace "[1;31mwarning: ${w}[0m" x) res config.warnings;
|
|
|
|
|
|
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;
|
2019-05-04 13:38:17 +00:00
|
|
|
|
type = types.attrsOf types.unspecified;
|
2016-10-18 21:14:18 +00:00
|
|
|
|
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-12-04 09:38:21 +00:00
|
|
|
|
system.profile = mkOption {
|
|
|
|
|
type = types.path;
|
|
|
|
|
default = "/nix/var/nix/profiles/system";
|
|
|
|
|
description = ''
|
|
|
|
|
Profile to use for the system.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2017-01-08 12:11:02 +00:00
|
|
|
|
assertions = mkOption {
|
|
|
|
|
type = types.listOf types.unspecified;
|
|
|
|
|
internal = true;
|
|
|
|
|
default = [];
|
|
|
|
|
example = [ { assertion = false; message = "you can't enable this for that reason"; } ];
|
|
|
|
|
description = ''
|
|
|
|
|
This option allows modules to express conditions that must
|
|
|
|
|
hold for the evaluation of the system configuration to
|
|
|
|
|
succeed, along with associated error messages for the user.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
warnings = mkOption {
|
|
|
|
|
internal = true;
|
|
|
|
|
default = [];
|
|
|
|
|
type = types.listOf types.str;
|
|
|
|
|
example = [ "The `foo' service is deprecated and will go away soon!" ];
|
|
|
|
|
description = ''
|
|
|
|
|
This option allows modules to show warnings to users during
|
|
|
|
|
the evaluation of the system configuration.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2016-10-18 21:14:18 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
config = {
|
|
|
|
|
|
2017-01-08 12:11:02 +00:00
|
|
|
|
system.build.toplevel = throwAssertions (showWarnings (stdenvNoCC.mkDerivation {
|
2016-12-19 20:09:10 +00:00
|
|
|
|
name = "darwin-system-${cfg.darwinLabel}";
|
2016-10-29 20:40:55 +00:00
|
|
|
|
preferLocalBuild = true;
|
|
|
|
|
|
2016-11-01 20:25:22 +00:00
|
|
|
|
activationScript = cfg.activationScripts.script.text;
|
2016-12-14 11:32:20 +00:00
|
|
|
|
activationUserScript = cfg.activationScripts.userScript.text;
|
2016-12-19 20:09:10 +00:00
|
|
|
|
inherit (cfg) darwinLabel;
|
2016-10-29 20:40:55 +00:00
|
|
|
|
|
|
|
|
|
buildCommand = ''
|
|
|
|
|
mkdir $out
|
|
|
|
|
|
2016-12-02 22:54:46 +00:00
|
|
|
|
systemConfig=$out
|
|
|
|
|
|
2017-07-23 16:56:37 +00:00
|
|
|
|
mkdir -p $out/darwin
|
2018-01-13 13:20:13 +00:00
|
|
|
|
cp -f ${../../CHANGELOG} $out/darwin-changes
|
2017-07-23 16:56:37 +00:00
|
|
|
|
|
2016-10-29 20:40:55 +00:00
|
|
|
|
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
|
2017-05-20 12:23:05 +00:00
|
|
|
|
ln -s ${cfg.build.applications}/Applications $out/Applications
|
2019-02-17 10:21:12 +00:00
|
|
|
|
ln -s ${cfg.build.fonts}/Library/Fonts $out/Library/Fonts
|
2017-01-25 21:35:06 +00:00
|
|
|
|
ln -s ${cfg.build.launchd}/Library/LaunchAgents $out/Library/LaunchAgents
|
2016-11-07 20:00:23 +00:00
|
|
|
|
ln -s ${cfg.build.launchd}/Library/LaunchDaemons $out/Library/LaunchDaemons
|
|
|
|
|
|
2017-05-11 21:43:05 +00:00
|
|
|
|
mkdir -p $out/user/Library
|
|
|
|
|
ln -s ${cfg.build.launchd}/user/Library/LaunchAgents $out/user/Library/LaunchAgents
|
2017-05-11 19:21:39 +00:00
|
|
|
|
|
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
|
|
|
|
|
|
2016-12-14 11:32:20 +00:00
|
|
|
|
echo "$activationUserScript" > $out/activate-user
|
|
|
|
|
substituteInPlace $out/activate-user --subst-var out
|
|
|
|
|
chmod u+x $out/activate-user
|
|
|
|
|
unset activationUserScript
|
|
|
|
|
|
2016-12-02 22:54:46 +00:00
|
|
|
|
echo -n "$systemConfig" > $out/systemConfig
|
|
|
|
|
|
2016-12-19 20:09:10 +00:00
|
|
|
|
echo -n "$darwinLabel" > $out/darwin-version
|
2016-10-29 20:40:55 +00:00
|
|
|
|
echo -n "$system" > $out/system
|
|
|
|
|
'';
|
2017-01-08 12:11:02 +00:00
|
|
|
|
}));
|
2016-10-18 21:14:18 +00:00
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
}
|