yep, more dotfiles
1{ lib 2, pkgs 3 4, modulesPath 5, ... 6}: 7 8let 9 inherit (pkgs) writeShellScriptBin pastebinit; 10 11 keys = import ../../secrets/keys.nix; 12 13 binName = drv: drv.meta.mainProgram; 14 15 flakeUri = "github:mrnossiom/dotfiles/nixos"; 16 17 ## Wireless related 18 19 # connect-wifi <interface> <BSSID> 20 connect-wifi = writeShellScriptBin "connect-wifi" '' 21 if [ -z "$1" ]; then echo "Interface unset"; exit; fi 22 if [ -z "$2" ]; then echo "SSID unset"; exit; fi 23 24 CONFIG=$(mktemp) 25 wpa_passphrase $2 > $CONFIG 26 sudo wpa_supplicant -B -i$1 -c$CONFIG 27 ''; 28 29 ## Formatting related 30 31 # Does the whole destroy, format, mount disko cycle 32 # disko-cycle <hostname> 33 disko-cycle = writeShellScriptBin "disko-cycle" '' 34 if [ -z "$1" ]; then echo "Hostname unset"; exit; fi 35 36 echo "Running disko destroy, format and mount script for $1" 37 nix build ${flakeUri}#nixosConfigurations.$1.config.system.build.diskoScript 38 sudo bash result 39 ''; 40 41 ## NixOS install related 42 43 # Generates hardware related config and uploads it to pastebin 44 # link-hardware-config [root] 45 link-hardware-config = writeShellScriptBin "link-hardware-config" '' 46 nixos-generate-config --root ''${1:-/mnt} --show-hardware-config | ${lib.getExe' pastebinit "pastebinit"} 47 ''; 48 49 # Install specified flake system to /mnt 50 # install-system <hostname> 51 install-system = writeShellScriptBin "install-system" '' 52 if [ -z "$1" ]; then echo "Hostname unset"; exit; fi 53 54 echo "Installing $1" 55 nixos-install --system ${flakeUri}#$1 56 ''; 57 58in 59{ 60 imports = [ "${modulesPath}/installer/cd-dvd/installation-cd-minimal-new-kernel.nix" ]; 61 62 config = { 63 # Default compression is never-ending, this gets done in a minute with better results 64 isoImage.squashfsCompression = "zstd -Xcompression-level 10"; 65 66 # Disable annoying warning 67 boot.swraid.enable = lib.mkForce false; 68 69 boot.kernelPackages = lib.mkForce pkgs.linuxKernel.packages.linux_6_6; 70 71 nix.settings = { 72 experimental-features = [ "nix-command" "flakes" ]; 73 extra-substituters = [ "https://nix-community.cachix.org" ]; 74 extra-trusted-public-keys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" ]; 75 }; 76 77 # Add our keys to default users for better remote experience 78 users.users.nixos.openssh.authorizedKeys.keys = keys.users; 79 80 # Start wpa_supplicant right away 81 systemd.services.wpa_supplicant.wantedBy = lib.mkForce [ "multi-user.target" ]; 82 83 services.getty.helpLine = '' 84 Available custom tools: 85 - Networking: ${binName connect-wifi} 86 - File System: ${binName disko-cycle} 87 - Installation: ${binName link-hardware-config}, ${binName install-system} 88 89 Troubleshoot: 90 - If the disko installer fails to finish due to a dark error just wipe the disk table 91 $ parted /dev/<disk-id> -- mklabel gpt 92 ''; 93 94 environment.systemPackages = [ 95 connect-wifi 96 disko-cycle 97 link-hardware-config 98 install-system 99 ]; 100 }; 101}