mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-15 17:51:01 +00:00
only activate system profile with sudo
This commit is contained in:
parent
1ab74daf82
commit
033499c0ed
4 changed files with 17 additions and 8 deletions
13
config.nix
13
config.nix
|
@ -62,6 +62,8 @@ let
|
||||||
environment.variables.EDITOR = "vim";
|
environment.variables.EDITOR = "vim";
|
||||||
environment.variables.HOMEBREW_CASK_OPTS = "--appdir=/Applications/cask";
|
environment.variables.HOMEBREW_CASK_OPTS = "--appdir=/Applications/cask";
|
||||||
|
|
||||||
|
environment.variables.SHELL = "${pkgs.lnl.zsh}/bin/zsh";
|
||||||
|
|
||||||
environment.variables.GIT_SSL_CAINFO = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
|
environment.variables.GIT_SSL_CAINFO = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
|
||||||
environment.variables.SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
|
environment.variables.SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
|
||||||
|
|
||||||
|
@ -95,11 +97,11 @@ let
|
||||||
case $cmd in
|
case $cmd in
|
||||||
'b'|'build') nix-build --no-out-link -E "with import <nixpkgs> {}; $@" ;;
|
'b'|'build') nix-build --no-out-link -E "with import <nixpkgs> {}; $@" ;;
|
||||||
'e'|'eval') nix-instantiate --eval -E "with import <nixpkgs> {}; $@" ;;
|
'e'|'eval') nix-instantiate --eval -E "with import <nixpkgs> {}; $@" ;;
|
||||||
'i'|'instantiate') nix-instantiate -E "with import <nixpkgs> {}; $@" ;;
|
'i'|'instantiate') nix-instantiate -E "with import <nixpkgs> {}; $@" ;;
|
||||||
'r'|'repl') nix-repl '<nixpkgs>' ;;
|
'r'|'repl') nix-repl '<nixpkgs>' ;;
|
||||||
's'|'shell') nix-shell -E "with import <nixpkgs> {}; $@" ;;
|
's'|'shell') nix-shell -E "with import <nixpkgs> {}; $@" ;;
|
||||||
'x'|'exec') nix-shell '<nixpkgs>' -p "$@" --run zsh ;;
|
'p'|'package') nix-shell '<nixpkgs>' -p "$@" --run ${pkgs.lnl.zsh} ;;
|
||||||
'z'|'zsh') nix-shell '<nixpkgs>' -A "$@" --run zsh ;;
|
'z'|'zsh') nix-shell '<nixpkgs>' -E "with import <nixpkgs> {}; $@" --run ${pkgs.lnl.zsh} ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,8 +112,9 @@ let
|
||||||
case $cmd in
|
case $cmd in
|
||||||
'build') nix-build '<nixpkgs>' -A nixdarwin.toplevel "$@" ;;
|
'build') nix-build '<nixpkgs>' -A nixdarwin.toplevel "$@" ;;
|
||||||
'repl') nix-repl "$HOME/.nixpkgs/config.nix" "$@" ;;
|
'repl') nix-repl "$HOME/.nixpkgs/config.nix" "$@" ;;
|
||||||
'shell') nix-shell '<nixpkgs>' -p nixdarwin.toplevel --run '${pkgs.lnl.zsh}/bin/zsh -l' "$@" ;;
|
'shell') nix-shell '<nixpkgs>' -p nixdarwin.toplevel --run ${pkgs.lnl.zsh}/bin/zsh "$@" ;;
|
||||||
'switch') sudo nix-env --profile ${config.system.profile} --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 ;;
|
'exec') __ETC_ZSHRC_SOURCED= __ETC_ZSHENV_SOURCED= __ETC_ZPROFILE_SOURCED= exec ${pkgs.lnl.zsh}/bin/zsh -l ;;
|
||||||
|
'switch') systemConfig=$(nix-build --no-out-link '<nixpkgs>' -A nixdarwin.toplevel) && nix-shell '<nixpkgs>' -A nixdarwin.toplevel --run 'sudo $out/activate' && sudo nix-env --profile ${config.system.profile} --set $systemConfig ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,12 @@ with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
inherit (pkgs) stdenv;
|
||||||
|
|
||||||
cfg = config.services.activate-system;
|
cfg = config.services.activate-system;
|
||||||
|
|
||||||
activateScript = pkgs.writeScript "activate-system" ''
|
activateScript = pkgs.writeScript "activate-system" ''
|
||||||
#! ${pkgs.stdenv.shell}
|
#! ${stdenv.shell}
|
||||||
|
|
||||||
# Make this configuration the current configuration.
|
# Make this configuration the current configuration.
|
||||||
# The readlink is there to ensure that when $systemConfig = /system
|
# The readlink is there to ensure that when $systemConfig = /system
|
||||||
|
|
|
@ -4,6 +4,8 @@ with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
inherit (pkgs) stdenv;
|
||||||
|
|
||||||
cfg = config.system;
|
cfg = config.system;
|
||||||
|
|
||||||
script = import ./write-text.nix {
|
script = import ./write-text.nix {
|
||||||
|
@ -35,7 +37,7 @@ in
|
||||||
config = {
|
config = {
|
||||||
|
|
||||||
system.activationScripts.script.text = ''
|
system.activationScripts.script.text = ''
|
||||||
#! ${pkgs.stdenv.shell}
|
#! ${stdenv.shell}
|
||||||
|
|
||||||
systemConfig=@out@
|
systemConfig=@out@
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
inherit (pkgs) stdenvNoCC;
|
||||||
|
|
||||||
cfg = config.system;
|
cfg = config.system;
|
||||||
|
|
||||||
in
|
in
|
||||||
|
@ -44,7 +46,7 @@ in
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
|
||||||
system.build.toplevel = pkgs.stdenvNoCC.mkDerivation {
|
system.build.toplevel = stdenvNoCC.mkDerivation {
|
||||||
name = "nixdarwin-system-${cfg.nixdarwinLabel}";
|
name = "nixdarwin-system-${cfg.nixdarwinLabel}";
|
||||||
preferLocalBuild = true;
|
preferLocalBuild = true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue