Files
nixos/overlays/inject.nix
T

57 lines
1.4 KiB
Nix
Raw Normal View History

2023-06-28 23:53:07 -05:00
{
pkgs,
git,
...
}:
2023-06-28 23:10:07 -05:00
2023-06-28 23:42:14 -05:00
pkgs.writeShellScriptBin "inject-nixos-config" ''
hostname="''${1}"
if [ -n "''${hostname}"]; then
echo "You must provide a hostname";
exit 1;
fi
2023-06-28 23:44:03 -05:00
mv /etc/nixos /etc/nixos.bk
2023-06-28 23:53:07 -05:00
cd /etc
${git}/bin/git clone http://github.com/greg-hellings/nixos-config nixos
2023-06-28 23:42:14 -05:00
mkdir -p "/etc/nixos/hosts/''${hostname}"
# Prepares everything for the flake usage
2024-04-16 08:55:08 -05:00
#cp /etc/nixos.bk/configuration.nix "/etc/nixos/hosts/''${hostname}/default.nix"
2024-04-16 09:05:02 -05:00
cat << EOF > "/etc/nixos/hosts/''${hostname}/default.nix"
2024-04-16 08:55:08 -05:00
{ pkgs, config, ... }:
{
imports = [ ./hardware-configuration.nix ];
boot.loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
networking.hostName = "''${hostname}";
greg = {
home = true;
tailscale.enable = true;
};
}
EOF
2023-06-28 23:42:14 -05:00
cp /etc/nixos.bk/hardware-configuration.nix "/etc/nixos/hosts/''${hostname}/hardware-configuration.nix"
2024-04-16 08:34:16 -05:00
# Prepare home-manager portion for setup
mkdir -p "/etc/nixos/home/hosts/''${hostname}"
2024-04-16 09:05:02 -05:00
cat << EOF > "/etc/nixos/home/hosts/''${hostname}/default.nix"
2024-04-16 08:34:16 -05:00
{ pkgs, config, ... }:
{
}
EOF
2023-06-28 23:42:14 -05:00
# Prepares it for injecting the use case into the flake usage
cp /etc/nixos.bk/hardware-configuration.nix /etc/nixos
2023-06-28 23:53:07 -05:00
chown -R greg nixos
2023-06-28 23:42:14 -05:00
2024-04-16 09:05:02 -05:00
echo "Now you should be able to just run `nixos-rebuild switch` to enable the flake functionality"
echo "After that and adding the entry to the flake, run `nixos-rebuild boot --flake '.#''${hostname}'` and reboot"
2023-06-28 23:42:14 -05:00
''