2024-10-03 11:26:39 -05:00
|
|
|
{ pkgs
|
|
|
|
|
, coreutils
|
|
|
|
|
, curl
|
|
|
|
|
, gnutar
|
|
|
|
|
, nix
|
|
|
|
|
, ...
|
2024-02-19 11:10:49 -06:00
|
|
|
}:
|
|
|
|
|
pkgs.writeShellScriptBin "inject-darwin" ''
|
2024-10-03 11:26:39 -05:00
|
|
|
set -ex
|
|
|
|
|
set -o pipefail
|
2024-02-19 11:10:49 -06:00
|
|
|
|
2024-10-03 11:26:39 -05:00
|
|
|
dir="$(${coreutils}/bin/mktemp -d)"
|
|
|
|
|
cd "''${dir}"
|
2024-02-19 11:10:49 -06:00
|
|
|
|
2024-10-03 11:26:39 -05:00
|
|
|
# Install nix-darwin
|
|
|
|
|
${nix}/bin/nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer
|
|
|
|
|
./result/bin/darwin-installer
|
2024-02-19 11:10:49 -06:00
|
|
|
|
2024-10-03 11:26:39 -05:00
|
|
|
# Get my configuration
|
|
|
|
|
mkdir -p ~/.config/darwin
|
|
|
|
|
cd ~/.config/darwin
|
|
|
|
|
${curl}/bin/curl -O -L https://github.com/greg-hellings/nixos-config/archive/refs/heads/main.tar.gz
|
|
|
|
|
${gnutar}/bin/tar xvzf main.tar.gz --strip-components 1
|
2024-02-19 11:10:49 -06:00
|
|
|
|
2024-10-03 11:26:39 -05:00
|
|
|
# Build NixOS for this system
|
|
|
|
|
pushd "''${dir}"
|
|
|
|
|
${nix}/bin/nix build "~/.config/darwin#darwinConfigurations.$(hostname -s).system"
|
|
|
|
|
./result/sw/bin/darwin-rebuild switch --flake ~/.config/darwin
|
|
|
|
|
popd
|
|
|
|
|
rm -r "''${dir}"
|
2024-02-19 11:10:49 -06:00
|
|
|
''
|