Files
nixos/overlays/inject.nix
T

26 lines
1.0 KiB
Nix
Raw Normal View History

2023-06-28 23:10:07 -05:00
{ pkgs, ... }:
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
${pkgs.curl}/bin/curl -L -o "''${HOME}/nixos-config.tar.gz" https://github.com/greg-hellings/nixos-config/archive/refs/heads/main.tar.gz
${pkgs.gnutar}/bin/tar xaf "''${HOME}/nixos-config.tar.gz" -C "''${HOME}"
2023-06-28 23:44:03 -05:00
mv /etc/nixos /etc/nixos.bk
mv "''${HOME}/nixos-config-main/" /etc/nixos
2023-06-28 23:42:14 -05:00
mkdir -p "/etc/nixos/hosts/''${hostname}"
# Prepares everything for the flake usage
cp /etc/nixos.bk/configuration.nix "/etc/nixos/hosts/''${hostname}/default.nix"
cp /etc/nixos.bk/hardware-configuration.nix "/etc/nixos/hosts/''${hostname}/hardware-configuration.nix"
# Prepares it for injecting the use case into the flake usage
cp /etc/nixos.bk/hardware-configuration.nix /etc/nixos
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"
''