mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-05 08:17:01 +00:00
global current-system
This commit is contained in:
parent
23a0eefe2d
commit
f81d86d2cb
2 changed files with 49 additions and 7 deletions
11
config.nix
11
config.nix
|
@ -51,6 +51,8 @@ let
|
|||
environment.etc."tmux.conf".text = ''
|
||||
source-file ${config.system.build.setTmuxOptions}
|
||||
|
||||
bind 0 set status
|
||||
|
||||
set -g status-bg black
|
||||
set -g status-fg white
|
||||
'';
|
||||
|
@ -65,9 +67,10 @@ let
|
|||
bindkey -e
|
||||
setopt autocd
|
||||
|
||||
export PROMPT='%B%(?..[%?] )%b> '
|
||||
export PROMPT='%B%(?..[%?] )%b⇒ '
|
||||
export RPROMPT='%F{green}%~%f'
|
||||
|
||||
export PATH=/var/run/current-system/sw/bin:/var/run/current-system/sw/bin''${PATH:+:$PATH}
|
||||
export PATH=/nix/var/nix/profiles/default/bin:/nix/var/nix/profiles/default/sbin''${PATH:+:$PATH}
|
||||
export PATH=$HOME/.nix-profile/bin:$HOME/.nix-profile/bin''${PATH:+:$PATH}
|
||||
|
||||
|
@ -76,10 +79,10 @@ let
|
|||
|
||||
nixdarwin-rebuild () {
|
||||
case $1 in
|
||||
"build") nix-build --no-out-link "<nixpkgs>" -A nixdarwin.toplevel ;;
|
||||
"build") nix-build --no-out-link '<nixpkgs>' -A nixdarwin.toplevel ;;
|
||||
"repl") nix-repl "$HOME/.nixpkgs/config.nix" ;;
|
||||
"shell") nix-shell "<nixpkgs>" -p nixdarwin.toplevel --run "zsh -l" ;;
|
||||
"switch") nix-env -f "<nixpkgs>" -iA nixdarwin.toplevel && exec zsh -l ;;
|
||||
"shell") nix-shell '<nixpkgs>' -p nixdarwin.toplevel --run "zsh -l" ;;
|
||||
"switch") nix-env -f '<nixpkgs>' -iA nixdarwin.toplevel && nix-shell '<nixpkgs>' -A nixdarwin.toplevel --run 'sudo $out/activate' && exec zsh -l ;;
|
||||
"") return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
|
|
@ -26,6 +26,11 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
system.nixdarwinLabel = mkOption {
|
||||
type = types.str;
|
||||
default = "16.09";
|
||||
};
|
||||
|
||||
# Used by <nixos/modules/system/etc/etc.nix>
|
||||
system.activationScripts = mkOption { internal = true; };
|
||||
|
||||
|
@ -33,9 +38,43 @@ in {
|
|||
|
||||
config = {
|
||||
|
||||
system.build.toplevel = pkgs.buildEnv {
|
||||
name = "nixdarwin-system";
|
||||
paths = [ cfg.path cfg.build.etc ];
|
||||
system.activationScripts.script = ''
|
||||
#! ${pkgs.stdenv.shell}
|
||||
|
||||
systemConfig=@out@
|
||||
|
||||
# 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 "$(readlink -f "$systemConfig")" /run/current-system
|
||||
|
||||
# Prevent the current configuration from being garbage-collected.
|
||||
ln -sfn /run/current-system /nix/var/nix/gcroots/current-system
|
||||
|
||||
'';
|
||||
|
||||
system.build.toplevel = pkgs.stdenvNoCC.mkDerivation {
|
||||
name = "nixdarwin-system-${cfg.nixdarwinLabel}";
|
||||
preferLocalBuild = true;
|
||||
|
||||
activationScript = config.system.activationScripts.script;
|
||||
inherit (cfg) nixdarwinLabel;
|
||||
|
||||
buildCommand = ''
|
||||
mkdir $out
|
||||
|
||||
ln -s ${cfg.build.etc}/etc $out/etc
|
||||
ln -s ${cfg.path} $out/sw
|
||||
|
||||
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
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue