1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-12-14 11:57:34 +00:00

only activate system profile with sudo

This commit is contained in:
Daiderd Jordan 2016-12-07 23:06:18 +01:00
parent 1ab74daf82
commit 033499c0ed
No known key found for this signature in database
GPG key ID: D02435D05B810C96
4 changed files with 17 additions and 8 deletions

View file

@ -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";
@ -98,8 +100,8 @@ let
'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
} }

View file

@ -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

View file

@ -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@

View file

@ -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;