Compare commits
2 commits
62adee6a89
...
d3f2fcb28e
Author | SHA1 | Date | |
---|---|---|---|
d3f2fcb28e | |||
8e712c486c |
2 changed files with 7 additions and 121 deletions
52
README.md
52
README.md
|
@ -1,3 +1,7 @@
|
||||||
|
# WARNING
|
||||||
|
|
||||||
|
## This configuration is not meant for public usage
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
|
|
||||||
## Remote (with NixOS Anywhere)
|
## Remote (with NixOS Anywhere)
|
||||||
|
@ -14,12 +18,10 @@
|
||||||
|
|
||||||
4. Create machine-specific modules in `machines/MACHINE/`
|
4. Create machine-specific modules in `machines/MACHINE/`
|
||||||
|
|
||||||
a. If [Home Manager](https://github.com/nix-community/home-manager), home configuration in `home.nix`
|
b. Machine configuration and hostname in `default.nix`
|
||||||
|
|
||||||
b. System configuration and hostname in `system.nix`
|
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ networking.hostName = "MACHINE"; }
|
{ custom.hostname = "MACHINE"; }
|
||||||
```
|
```
|
||||||
|
|
||||||
c. [Disko](https://github.com/nix-community/disko) layout in `disko.nix`
|
c. [Disko](https://github.com/nix-community/disko) layout in `disko.nix`
|
||||||
|
@ -38,12 +40,10 @@
|
||||||
nixos-generate-config --show-hardware-config --no-filesystems --root /mnt
|
nixos-generate-config --show-hardware-config --no-filesystems --root /mnt
|
||||||
```
|
```
|
||||||
|
|
||||||
e. Import modules in `default.nix`
|
|
||||||
|
|
||||||
5. Choose profile and add machine-specific modules to `flake.in.nix`
|
5. Choose profile and add machine-specific modules to `flake.in.nix`
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
MACHINE = linux [ ./profiles/PROFILE ./machines/MACHINE ];
|
MACHINE = BRANCH [ ./profiles/PROFILE ./machines/MACHINE ];
|
||||||
```
|
```
|
||||||
|
|
||||||
6. Generate `flake.nix` with [flakegen](https://github.com/jorsn/flakegen)
|
6. Generate `flake.nix` with [flakegen](https://github.com/jorsn/flakegen)
|
||||||
|
@ -74,41 +74,3 @@
|
||||||
```
|
```
|
||||||
|
|
||||||
9. Shutdown, detach ISO, and reboot
|
9. Shutdown, detach ISO, and reboot
|
||||||
|
|
||||||
## Local (with script)
|
|
||||||
|
|
||||||
1. Clone repository using personal access token
|
|
||||||
|
|
||||||
```sh
|
|
||||||
git clone https://TOKEN@github.com/Myned/nixos /tmp/nixos
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Go to repository directory
|
|
||||||
|
|
||||||
```sh
|
|
||||||
cd /tmp/nixos
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Check disk layout
|
|
||||||
|
|
||||||
```sh
|
|
||||||
lsblk
|
|
||||||
```
|
|
||||||
|
|
||||||
4. Modify disko layout to match hardware
|
|
||||||
|
|
||||||
```sh
|
|
||||||
nano machine/MACHINE/disko.nix
|
|
||||||
```
|
|
||||||
|
|
||||||
5. Execute install script
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo nix --experimental-features 'nix-command flakes' run nixpkgs#fish -- install.fish
|
|
||||||
```
|
|
||||||
|
|
||||||
6. Optionally shred personal access token
|
|
||||||
|
|
||||||
```sh
|
|
||||||
shred -zu github.token
|
|
||||||
```
|
|
||||||
|
|
76
install.fish
76
install.fish
|
@ -1,76 +0,0 @@
|
||||||
#!/usr/bin/env fish
|
|
||||||
# sudo nix --experimental-features 'nix-command flakes' run nixpkgs#fish -- install.fish
|
|
||||||
|
|
||||||
# Wrap command execution in log output with error handling
|
|
||||||
function execute
|
|
||||||
if $argv &>>install.log
|
|
||||||
echo " done."
|
|
||||||
else
|
|
||||||
echo " error."
|
|
||||||
exit 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Alias nix to enable flakes
|
|
||||||
alias nix "nix --experimental-features 'nix-command flakes'"
|
|
||||||
|
|
||||||
# Gather variables
|
|
||||||
set -l machine (read -P "Enter machine hostname: ")
|
|
||||||
set -l secret (read -P "Enter encryption secret: ")
|
|
||||||
|
|
||||||
# Clear logfile
|
|
||||||
echo "Logging to install.log..."
|
|
||||||
rm install.log &>/dev/null
|
|
||||||
|
|
||||||
# Create keyfile
|
|
||||||
echo -n "Creating secret.key..."
|
|
||||||
execute nix run nixpkgs#fish -- -c "echo -n $secret > /tmp/secret.key"
|
|
||||||
|
|
||||||
# Format disks
|
|
||||||
echo -n "Formatting disks..."
|
|
||||||
execute nix run disko -- -m disko machines/$machine/disko.nix
|
|
||||||
|
|
||||||
# Shred keyfile
|
|
||||||
echo -n "Shredding secret.key..."
|
|
||||||
execute shred -zu /tmp/secret.key
|
|
||||||
|
|
||||||
# Generate hardware configuration
|
|
||||||
echo -n "Generating hardware-configuration.nix..."
|
|
||||||
execute nixos-generate-config --no-filesystems --root /mnt --dir .
|
|
||||||
|
|
||||||
# Move hardware configuration
|
|
||||||
echo -n "Moving hardware-configuration.nix to machines/$machine/..."
|
|
||||||
execute mv hardware-configuration.nix machines/$machine/
|
|
||||||
|
|
||||||
# Stage files in git tree for flake to access
|
|
||||||
git add .
|
|
||||||
|
|
||||||
# Update flake
|
|
||||||
echo -n "Updating flake.lock..."
|
|
||||||
execute nix flake update
|
|
||||||
|
|
||||||
# Confirm installation of NixOS
|
|
||||||
while true
|
|
||||||
switch (read -P "Install NixOS? [Y/N] ")
|
|
||||||
case Y y
|
|
||||||
break
|
|
||||||
case N n
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Install NixOS
|
|
||||||
echo -n "Installing..."
|
|
||||||
execute nixos-install --no-root-password --flake .#$machine
|
|
||||||
|
|
||||||
# Update git remote to remove personal access token
|
|
||||||
echo -n "Updating git remotes..."
|
|
||||||
git remote rm origin
|
|
||||||
execute git remote add git@github.com/Myned/nixos.git
|
|
||||||
|
|
||||||
# Copy NixOS configuration to system
|
|
||||||
echo -n "Copying NixOS configuration to /mnt/etc/nixos/..."
|
|
||||||
execute cp -r . /mnt/etc/nixos/
|
|
||||||
|
|
||||||
# Finish
|
|
||||||
echo "Installation finished. Reboot when ready."
|
|
Loading…
Add table
Reference in a new issue