1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-10 02:37:07 +00:00
nix-darwin/modules/system/default.nix

81 lines
1.6 KiB
Nix
Raw Normal View History

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