-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.nix
45 lines (39 loc) · 1.46 KB
/
shell.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{ pkgs }:
let
isDarwin = pkgs.stdenvNoCC.isDarwin;
configuration = if isDarwin then
"$HOME/.config/.nixpkgs/darwin/default.nix"
else
"/etc/nixos/configuration.nix";
systemSetup = ''
set -e
echo >&2 "Installing Nix-Darwin..."
# setup /run directory for darwin system installations
if ! grep -q '^run\b' /etc/synthetic.conf 2>/dev/null; then
echo "setting up /etc/synthetic.conf..."
echo -e "run\tprivate/var/run" | sudo tee -a /etc/synthetic.conf >/dev/null
/System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -B 2>/dev/null || true
/System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -t 2>/dev/null || true
fi
if ! test -L /run; then
echo "setting up /run..."
sudo ln -sfn private/var/run /run
fi
'';
darwinBuild = ''
${pkgs.nixFlakes}/bin/nix build ".#darwinConfigurations.luca-macbookpro.system" --experimental-features "flakes nix-command" --show-trace
'';
darwinInstall = pkgs.writeShellScriptBin "darwinInstall" ''
${systemSetup}
${darwinBuild}
sudo ./result/activate
'';
darwinTest = pkgs.writeShellScriptBin "darwinTest" ''
${darwinBuild}
'';
homebrewInstall = pkgs.writeShellScriptBin "homebrewInstall" ''
${pkgs.bash}/bin/bash -c "$(${pkgs.curl}/bin/curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
'';
in pkgs.mkShell {
buildInputs = [ pkgs.nixFlakes darwinTest darwinInstall homebrewInstall ];
}