mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-05 08:17:01 +00:00
move nix-tools out of nix expression
This commit is contained in:
parent
98f6b407ec
commit
8708ebb796
7 changed files with 99 additions and 76 deletions
|
@ -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
|
||||
|
|
41
modules/nix/nix-darwin.nix
Normal file
41
modules/nix/nix-darwin.nix
Normal 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
|
||||
];
|
||||
|
||||
};
|
||||
}
|
|
@ -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
|
||||
];
|
||||
|
||||
};
|
||||
}
|
|
@ -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
12
pkgs/nix-tools/darwin-option.sh
Executable file
|
@ -0,0 +1,12 @@
|
|||
#! @shell@
|
||||
set -e
|
||||
set -o pipefail
|
||||
export PATH=@path@:$PATH
|
||||
|
||||
|
||||
showSyntax() {
|
||||
echo "$0: not implemented" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
showSyntax
|
42
pkgs/nix-tools/darwin-rebuild.sh
Normal file
42
pkgs/nix-tools/darwin-rebuild.sh
Normal 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
|
|
@ -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
|
||||
'';
|
||||
}
|
Loading…
Add table
Reference in a new issue