1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-16 05:18:17 +00:00
nix-darwin/modules/system/default.nix
2016-11-07 21:00:23 +01:00

66 lines
1.3 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.system;
in
{
options = {
system.build = mkOption {
internal = true;
default = {};
description = ''
Attribute set of derivation used to setup the system.
'';
};
system.path = mkOption {
internal = true;
type = types.package;
description = ''
The packages you want in the system environment.
'';
};
system.nixdarwinLabel = mkOption {
type = types.str;
default = "16.09";
};
};
config = {
system.build.toplevel = pkgs.stdenvNoCC.mkDerivation {
name = "nixdarwin-system-${cfg.nixdarwinLabel}";
preferLocalBuild = true;
activationScript = cfg.activationScripts.script.text;
inherit (cfg) nixdarwinLabel;
buildCommand = ''
mkdir $out
ln -s ${cfg.build.etc}/etc $out/etc
ln -s ${cfg.path} $out/sw
mkdir -p $out/Library
ln -s ${cfg.build.launchd}/Library/LaunchDaemons $out/Library/LaunchDaemons
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
'';
};
};
}