1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-05 16:27:03 +00:00

improve system activation

This commit is contained in:
Daiderd Jordan 2016-12-02 23:54:46 +01:00
parent b0e55cb39e
commit 61a91d3c99
No known key found for this signature in database
GPG key ID: D02435D05B810C96
3 changed files with 27 additions and 6 deletions

View file

@ -36,17 +36,21 @@ let
pkgs.nox
];
launchd.daemons.nix-daemon =
{ serviceConfig.Program = "${pkgs.nix}/bin/nix-daemon";
serviceConfig.KeepAlive = true;
launchd.agents.activate-system =
{ serviceConfig.Program = "${config.system.build.activate}";
serviceConfig.RunAtLoad = true;
};
launchd.daemons.nix-daemon =
{ serviceConfig.Program = "/nix/var/nix/profiles/default/bin/nix-daemon";
serviceConfig.KeepAlive = true;
serviceConfig.ProcessType = "Background";
serviceConfig.SoftResourceLimits.NumberOfFiles = 4096;
serviceConfig.EnvironmentVariables.TMPDIR = "/nix/tmp";
serviceConfig.EnvironmentVariables.SSL_CERT_FILE = "/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt";
serviceConfig.EnvironmentVariables.NIX_BUILD_HOOK="/nix/var/nix/profiles/default/libexec/nix/build-remote.pl";
serviceConfig.EnvironmentVariables.NIX_CURRENT_LOAD="/nix/tmp/current-load";
serviceConfig.EnvironmentVariables.NIX_REMOTE_SYSTEMS="/etc/nix/machines";
serviceConfig.EnvironmentVariables.SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
serviceConfig.EnvironmentVariables.TMPDIR = "/nix/tmp";
};
system.defaults.global.InitialKeyRepeat = 10;
@ -114,7 +118,7 @@ let
shift
case $cmd in
'build') nix-build --no-out-link '<nixpkgs>' -A nixdarwin.toplevel "$@" ;;
'build') nix-build '<nixpkgs>' -A nixdarwin.toplevel "$@" ;;
'repl') nix-repl "$HOME/.nixpkgs/config.nix" "$@" ;;
'shell') nix-shell '<nixpkgs>' -p nixdarwin.toplevel --run '${pkgs.lnl.zsh}/bin/zsh -l' "$@" ;;
'switch') sudo nix-env --profile /nix/var/nix/profiles/system --set $(nix-build --no-out-link '<nixpkgs>' -A nixdarwin.toplevel) && nix-shell '<nixpkgs>' -A nixdarwin.toplevel --run 'sudo $out/activate' && exec ${pkgs.lnl.zsh}/bin/zsh -l ;;

View file

@ -34,6 +34,19 @@ in
config = {
system.build.activate = pkgs.writeText "activate-system" ''
#! ${pkgs.stdenv.shell}
# Make this configuration the current configuration.
# The readlink is there to ensure that when $systemConfig = /system
# (which is a symlink to the store), /run/current-system is still
# used as a garbage collection root.
ln -sfn $(cat /nix/var/nix/profiles/system/systemConfig) /run/current-system
# Prevent the current configuration from being garbage-collected.
ln -sfn /run/current-system /nix/var/nix/gcroots/current-system
'';
system.activationScripts.script.text = ''
#! ${pkgs.stdenv.shell}

View file

@ -46,6 +46,8 @@ in
buildCommand = ''
mkdir $out
systemConfig=$out
ln -s ${cfg.build.etc}/etc $out/etc
ln -s ${cfg.path} $out/sw
@ -57,6 +59,8 @@ in
chmod u+x $out/activate
unset activationScript
echo -n "$systemConfig" > $out/systemConfig
echo -n "$nixdarwinLabel" > $out/nixdarwin-version
echo -n "$system" > $out/system
'';