diff --git a/flake.nix b/flake.nix index 27a40de..ddd16ec 100644 --- a/flake.nix +++ b/flake.nix @@ -78,6 +78,7 @@ gzip inject sudo + tmux xonsh ]; })); diff --git a/overlays/inject.nix b/overlays/inject.nix index b59111c..20bf856 100644 --- a/overlays/inject.nix +++ b/overlays/inject.nix @@ -1,3 +1,25 @@ { pkgs, ... }: -pkgs.writeShellScriptBin "inject-nixos-config" (builtins.readFile ./inject.sh) +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}" +${pkgs.sudo}/bin/sudo mv /etc/nixos /etc/nixos.bk +${pkgs.sudo}/bin/sudo mv "''${HOME}/nixos-config-main/" /etc/nixos +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" +'' diff --git a/overlays/inject.sh b/overlays/inject.sh deleted file mode 100755 index 95edf06..0000000 --- a/overlays/inject.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -hostname="${1}" -if [ -n "${hostname}"]; then - echo "You must provide a hostname"; - exit 1; -fi - -curl -L -o "${HOME}/nixos-config.tar.gz" https://github.com/greg-hellings/nixos-config/archive/refs/heads/main.tar.gz -tar xaf "${HOME}/nixos-config.tar.gz" -C "${HOME}" -sudo mv /etc/nixos /etc/nixos.bk -sudo mv "${HOME}/nixos-config-main/" /etc/nixos -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" -