give it a whirl
This commit is contained in:
Executable
+84
@@ -0,0 +1,84 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# User variables
|
||||||
|
target_hostname=""
|
||||||
|
target_destination=""
|
||||||
|
target_administrator=""
|
||||||
|
target_user=${BOOTSTRAP_USER-root} # Set BOOTSTRAP_ defaults in your shell.nix
|
||||||
|
ssh_port=${BOOTSTRAP_SSH_PORT-22}
|
||||||
|
|
||||||
|
function help_and_exit() {
|
||||||
|
echo
|
||||||
|
echo "Remotely installs NixOS on a target machine using this nix-config."
|
||||||
|
echo
|
||||||
|
echo "USAGE: $0 -n <target_hostname> -d <target_destination> [OPTIONS]"
|
||||||
|
echo
|
||||||
|
echo "ARGS:"
|
||||||
|
echo " -n <target_hostname> specify target_hostname of the target host to deploy the nixos config on. (default I think)"
|
||||||
|
echo " -d <target_destination> specify ip or domain to the target host."
|
||||||
|
echo " -a <target_administrator> specify the name of the user that will act as the system administrator (roy)"
|
||||||
|
echo
|
||||||
|
echo "OPTIONS:"
|
||||||
|
echo " -u <target_user> specify target_user with sudo access. nix-config will be cloned to their home."
|
||||||
|
echo " Default=root."
|
||||||
|
echo " --port <ssh_port> specify the ssh port to use for remote access. Default=${ssh_port}."
|
||||||
|
echo " --debug Enable debug mode."
|
||||||
|
echo " -h | --help Print this help."
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to cleanup temporary directory on exit
|
||||||
|
cleanup() {
|
||||||
|
rm -rf "$temp"
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
# Handle command-line arguments
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
-n)
|
||||||
|
shift
|
||||||
|
target_hostname=$1
|
||||||
|
;;
|
||||||
|
-d)
|
||||||
|
shift
|
||||||
|
target_destination=$1
|
||||||
|
;;
|
||||||
|
-a)
|
||||||
|
shift
|
||||||
|
target_administrator=$1
|
||||||
|
;;
|
||||||
|
-u)
|
||||||
|
shift
|
||||||
|
target_user=$1
|
||||||
|
;;
|
||||||
|
--port)
|
||||||
|
shift
|
||||||
|
ssh_port=$1
|
||||||
|
;;
|
||||||
|
--debug)
|
||||||
|
set -x
|
||||||
|
;;
|
||||||
|
-h | --help) help_and_exit ;;
|
||||||
|
*)
|
||||||
|
echo "ERROR: Invalid option detected."
|
||||||
|
help_and_exit
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$target_hostname" ] || [ -z "$target_destination" ] || [ -z "$target_administrator" ]; then
|
||||||
|
echo "ERROR: -n, -d, and -a are all required"
|
||||||
|
echo
|
||||||
|
help_and_exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# delete known hosts
|
||||||
|
sed -i "/$target_hostname/d; /$target_destination/d" ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
# Install NixOS to the host system with our secrets
|
||||||
|
nix run github:nix-community/nixos-anywhere --extra-experimental-features "nix-command flakes" -- --ssh-port "$ssh_port" --post-kexec-ssh-port "$ssh_port" --generate-hardware-config nixos-generate-config ./hardware-configuration.nix --disko-mode disko --build-on local --flake .#"$target_hostname" --target-host "$target_user"@"$target_destination"
|
||||||
|
|
||||||
|
echo "Deploy Finished"
|
||||||
|
|
||||||
+3
-16
@@ -54,9 +54,6 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# needed to allowOther in home.nix
|
|
||||||
programs.fuse.userAllowOther = true;
|
|
||||||
|
|
||||||
networking.hostName = "roy-laptop";
|
networking.hostName = "roy-laptop";
|
||||||
networking.hostId = "4cb9fc76";
|
networking.hostId = "4cb9fc76";
|
||||||
|
|
||||||
@@ -160,6 +157,9 @@
|
|||||||
};
|
};
|
||||||
waybar.enable = true;
|
waybar.enable = true;
|
||||||
fish.enable = true;
|
fish.enable = true;
|
||||||
|
|
||||||
|
# needed to allowOther in home.nix
|
||||||
|
fuse.userAllowOther = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
programs = {
|
programs = {
|
||||||
@@ -171,19 +171,6 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
programs.firefox = {
|
|
||||||
enable = true;
|
|
||||||
policies = {
|
|
||||||
ExtensionSettings = {
|
|
||||||
"*".installation_mode = "blocked";
|
|
||||||
"uBlock0@raymondhill.net" = {
|
|
||||||
install_url = "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi";
|
|
||||||
installation_mode = "force_installed";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
environment.sessionVariables.NIXOS_OZONE_WL = "1";
|
environment.sessionVariables.NIXOS_OZONE_WL = "1";
|
||||||
|
|
||||||
environment.variables = {
|
environment.variables = {
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
disko.devices = {
|
||||||
|
disk = {
|
||||||
|
x = {
|
||||||
|
device = "/dev/nvme0n1";
|
||||||
|
type = "disk";
|
||||||
|
content = {
|
||||||
|
type = "gpt";
|
||||||
|
partitions = {
|
||||||
|
# boot
|
||||||
|
ESP = {
|
||||||
|
size = "1024M";
|
||||||
|
type = "EF00";
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "vfat";
|
||||||
|
mountpoint = "/boot";
|
||||||
|
mountOptions = [ "umask=0077" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
# root
|
||||||
|
zfs = {
|
||||||
|
size = "100%";
|
||||||
|
content = {
|
||||||
|
type = "zfs";
|
||||||
|
pool = "zroot";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
zpool = {
|
||||||
|
zroot = {
|
||||||
|
type = "zpool";
|
||||||
|
rootFsOptions = {
|
||||||
|
compression = "zstd";
|
||||||
|
"com.sun:auto-snapshot" = "false";
|
||||||
|
};
|
||||||
|
|
||||||
|
datasets = {
|
||||||
|
"root" = {
|
||||||
|
type = "zfs_fs";
|
||||||
|
options.mountpoint = "/";
|
||||||
|
mountpoint = "/";
|
||||||
|
postCreateHook = "zfs list -t snapshot -H -o name | grep -E '^zroot/root@blank$' || zfs snapshot zroot/root@blank";
|
||||||
|
};
|
||||||
|
"nix" = {
|
||||||
|
type = "zfs_fs";
|
||||||
|
options.mountpoint = "/nix";
|
||||||
|
mountpoint = "/nix";
|
||||||
|
};
|
||||||
|
"persist" = {
|
||||||
|
type = "zfs_fs";
|
||||||
|
options.mountpoint = "/persist";
|
||||||
|
mountpoint = "/persist";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -11,6 +11,10 @@
|
|||||||
url = "github:nix-community/home-manager/release-25.05";
|
url = "github:nix-community/home-manager/release-25.05";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
disko = {
|
||||||
|
url = "github:nix-community/disko";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
impermanence.url = "github:nix-community/impermanence";
|
impermanence.url = "github:nix-community/impermanence";
|
||||||
# implement at some point (So I can push repo public)
|
# implement at some point (So I can push repo public)
|
||||||
sops-nix = {
|
sops-nix = {
|
||||||
@@ -23,13 +27,15 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, nixvim, home-manager, impermanence, sops-nix, firefox-addons }@inputs: {
|
outputs = { self, nixpkgs, nixvim, home-manager, disko, impermanence, sops-nix, firefox-addons }@inputs: {
|
||||||
|
|
||||||
nixosConfigurations.default = nixpkgs.lib.nixosSystem {
|
nixosConfigurations.default = nixpkgs.lib.nixosSystem {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = [
|
modules = [
|
||||||
./configuration.nix
|
./configuration.nix
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
|
./disk-config.nix
|
||||||
|
disko.nixosModules.disko
|
||||||
impermanence.nixosModules.impermanence
|
impermanence.nixosModules.impermanence
|
||||||
sops-nix.nixosModules.sops
|
sops-nix.nixosModules.sops
|
||||||
home-manager.nixosModules.home-manager {
|
home-manager.nixosModules.home-manager {
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
|
||||||
# and may be overwritten by future invocations. Please make changes
|
|
||||||
# to /etc/nixos/configuration.nix instead.
|
|
||||||
{ config, lib, pkgs, modulesPath, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
imports =
|
|
||||||
[ (modulesPath + "/installer/scan/not-detected.nix")
|
|
||||||
];
|
|
||||||
|
|
||||||
boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ];
|
|
||||||
boot.initrd.kernelModules = [ ];
|
|
||||||
boot.kernelModules = [ "kvm-intel" ];
|
|
||||||
boot.extraModulePackages = [ ];
|
|
||||||
|
|
||||||
fileSystems."/" =
|
|
||||||
{ device = "zroot/root";
|
|
||||||
fsType = "zfs";
|
|
||||||
};
|
|
||||||
|
|
||||||
fileSystems."/boot" =
|
|
||||||
{ device = "/dev/disk/by-uuid/2755-9134";
|
|
||||||
fsType = "vfat";
|
|
||||||
options = [ "fmask=0077" "dmask=0077" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
fileSystems."/nix" =
|
|
||||||
{ device = "zroot/nix";
|
|
||||||
fsType = "zfs";
|
|
||||||
};
|
|
||||||
|
|
||||||
fileSystems."/persist" =
|
|
||||||
{ device = "zroot/persist";
|
|
||||||
fsType = "zfs";
|
|
||||||
};
|
|
||||||
|
|
||||||
swapDevices = [ ];
|
|
||||||
|
|
||||||
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
|
||||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
|
||||||
# still possible to use this option, but it's recommended to use it in conjunction
|
|
||||||
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
|
||||||
networking.useDHCP = lib.mkDefault true;
|
|
||||||
# networking.interfaces.wlo1.useDHCP = lib.mkDefault true;
|
|
||||||
|
|
||||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
|
||||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user