1
1
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-09-19 08:37:17 +03:00

move nix-tools out of nix expression

This commit is contained in:
Daiderd Jordan 2016-12-12 17:34:43 +01:00
parent 98f6b407ec
commit 8708ebb796
No known key found for this signature in database
GPG Key ID: D02435D05B810C96
7 changed files with 99 additions and 76 deletions

View File

@ -11,7 +11,7 @@ let
./modules/system/defaults
./modules/system/etc.nix
./modules/system/launchd.nix
./modules/nix/nix-tools.nix
./modules/nix/nix-darwin.nix
./modules/nix/nixpkgs.nix
./modules/environment
./modules/launchd

View File

@ -0,0 +1,41 @@
{ config, pkgs, ... }:
let
inherit (pkgs) stdenv;
writeProgram = name: env: src:
pkgs.substituteAll ({
inherit name src;
dir = "bin";
isExecutable = true;
} // env);
darwin-option = writeProgram "darwin-option"
{
inherit (config.system) profile;
inherit (stdenv) shell;
}
../../pkgs/nix-tools/darwin-option.sh;
darwin-rebuild = writeProgram "darwin-rebuild"
{
inherit (config.system) profile;
inherit (stdenv) shell;
path = "${pkgs.coreutils}/bin:${config.environment.systemPath}";
}
../../pkgs/nix-tools/darwin-rebuild.sh;
in
{
config = {
environment.systemPackages =
[ # Include nix-tools by default
darwin-option
darwin-rebuild
];
};
}

View File

@ -1,19 +0,0 @@
{ config, pkgs, ... }:
let
tools = pkgs.callPackage ../../pkgs/nix-tools {};
in
{
config = {
environment.systemPackages =
[ # Include nix-tools by default
tools.darwin-option
tools.darwin-rebuild
];
};
}

View File

@ -38,6 +38,9 @@ in
system.activationScripts.script.text = ''
#! ${stdenv.shell}
set -e
set -o pipefail
export PATH=${pkgs.coreutils}/bin:${config.environment.systemPath}:$PATH
systemConfig=@out@

12
pkgs/nix-tools/darwin-option.sh Executable file
View File

@ -0,0 +1,12 @@
#! @shell@
set -e
set -o pipefail
export PATH=@path@:$PATH
showSyntax() {
echo "$0: not implemented" >&2
exit 1
}
showSyntax

View File

@ -0,0 +1,42 @@
#! @shell@
set -e
set -o pipefail
export PATH=@path@:$PATH
showSyntax() {
exec man darwin-rebuild
exit 1
}
# Parse the command line.
origArgs=("$@")
action=
while [ "$#" -gt 0 ]; do
i="$1"; shift 1
case "$i" in
--help)
showSyntax
;;
switch|build)
action="$i"
;;
*)
echo "$0: unknown option \`$i'"
exit 1
;;
esac
done
if [ -z "$action" ]; then showSyntax; fi
echo "building the system configuration..." >&2
if [ "$action" = switch -o "$action" = build ]; then
systemConfig="$(nix-build '<darwin>' --no-out-link -A system)"
fi
if [ "$action" = switch ]; then
sudo nix-env -p @profile@ --set $systemConfig
sudo $systemConfig/activate
fi

View File

@ -1,56 +0,0 @@
{ stdenv, writeScriptBin, coreutils, nix }:
{
darwin-option = writeScriptBin "darwin-option" ''
#! ${stdenv.shell}
set -e
echo "$0: not implemented" >&2
exit 1
'';
darwin-rebuild = writeScriptBin "darwin-rebuild" ''
#! ${stdenv.shell}
set -e
showSyntax() {
exec man darwin-rebuild
exit 1
}
# Parse the command line.
origArgs=("$@")
action=
profile=/nix/var/nix/profiles/system
while [ "$#" -gt 0 ]; do
i="$1"; shift 1
case "$i" in
--help)
showSyntax
;;
switch|build)
action="$i"
;;
*)
echo "$0: unknown option \`$i'"
exit 1
;;
esac
done
if [ -z "$action" ]; then showSyntax; fi
export PATH=${coreutils}/bin:$PATH
echo "building the system configuration..." >&2
if [ "$action" = switch -o "$action" = build ]; then
systemConfig="$(nix-build '<darwin>' --no-out-link -A system)"
fi
if [ "$action" = switch ]; then
sudo nix-env -p "$profile" --set $systemConfig
sudo $systemConfig/activate
fi
'';
}