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

81 lines
1.6 KiB
Nix
Raw Normal View History

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;
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
};
system.profile = mkOption {
type = types.path;
default = "/nix/var/nix/profiles/system";
description = ''
Profile to use for the system.
'';
};
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-12-07 22:06:18 +00:00
system.build.toplevel = stdenvNoCC.mkDerivation {
2016-10-29 20:40:55 +00:00
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
2016-12-02 22:54:46 +00:00
systemConfig=$out
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
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
2016-12-02 22:54:46 +00:00
echo -n "$systemConfig" > $out/systemConfig
2016-10-29 20:40:55 +00:00
echo -n "$nixdarwinLabel" > $out/nixdarwin-version
echo -n "$system" > $out/system
'';
2016-10-18 21:14:18 +00:00
};
};
}