1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-12-15 17:51:01 +00:00
nix-darwin/modules/system/default.nix

67 lines
1.3 KiB
Nix
Raw Normal View History

2016-10-18 21:14:18 +00:00
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.system;
in
2016-11-01 20:25:22 +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
};
};
}