mirror of
https://codeberg.org/muon/home.git
synced 2025-12-05 23:57:46 +00:00
114 lines
3 KiB
Nix
114 lines
3 KiB
Nix
{
|
|
pkgs,
|
|
lib,
|
|
config,
|
|
osConfig,
|
|
inputs,
|
|
...
|
|
}: let
|
|
cfg = osConfig.mods;
|
|
installScript = pkgs.writeShellApplication {
|
|
name = "install-flake";
|
|
text = ''
|
|
echo "Cloning config..."
|
|
git clone https://codeberg.org/muon/home
|
|
cd home
|
|
nvim hosts/"$(hostname)"/disk-config.nix
|
|
|
|
echo "Running disko..."
|
|
sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- --mode destroy,format,mount hosts/"$(hostname)"/disk-config.nix
|
|
|
|
echo "Making blank root snapshot..."
|
|
sudo mkdir -p /tmp/mnt
|
|
sudo mount /dev/mapper/crypted /tmp/mnt
|
|
sudo btrfs subvolume snapshot -r /tmp/mnt/root /tmp/mnt/root-blank
|
|
sudo umount /tmp/mnt
|
|
|
|
echo "Retrieving sops key..."
|
|
rbw config set email admin@muon.host
|
|
rbw config set base_url https://vault.muon.host
|
|
rbw login
|
|
|
|
sudo mkdir -p /persist/var/lib/sops-nix
|
|
rbw get sops > /mnt/persist/var/lib/sops-nix/key.txt
|
|
sudo chown muon:users /mnt/persist/var/lib/sops-nix -R
|
|
|
|
echo "Setting hardware config..."
|
|
sudo nixos-generate-config --no-filesystems --root /mnt
|
|
cp /mnt/etc/nixos/hardware-configuration.nix hosts/"$(hostname)"/hardware-configuration.nix
|
|
|
|
echo "Installing NixOS config..."
|
|
sudo nixos-install --root /mnt --no-root-passwd --flake .#"$(hostname)"
|
|
|
|
echo "Edit persistent filesystem..."
|
|
PERSIST="$HOME/persist"
|
|
nvim "$PERSIST"
|
|
|
|
echo "Copying persistent filesystem..."
|
|
make_persist() {
|
|
F="/mnt$1"
|
|
P="/mnt/persist$1"
|
|
if [[ -d "$F" ]]; then
|
|
mkdir -p "$F" "$P"
|
|
elif [[ -f "$F" ]]; then
|
|
mkdir -p "$(dirname "$F")" "$(dirname "$P")"
|
|
else
|
|
echo "Error: $F does not exist!"
|
|
return 1
|
|
fi
|
|
cp -r "$F" "$P"
|
|
}
|
|
grep -v '^#' "$PERSIST" | while read -r file ; do
|
|
make_persist "$file"
|
|
done
|
|
'';
|
|
};
|
|
in {
|
|
# Install
|
|
home.file.persist = {
|
|
target = "persist.txt";
|
|
text = ''
|
|
/var/lib/nixos
|
|
/var/lib/systemd/coredump
|
|
/etc/NetworkManager
|
|
/var/lib/NetworkManager
|
|
/etc/machine-id
|
|
'';
|
|
};
|
|
home.packages = with pkgs;
|
|
[
|
|
installScript
|
|
]
|
|
# Modules
|
|
++ [
|
|
pulseaudio
|
|
pavucontrol
|
|
alsa-utils
|
|
];
|
|
|
|
mods.xdg.enable = true;
|
|
mods.i3.enable = true;
|
|
mods.battery.enable = true;
|
|
mods.terminal.zsh.enable = true;
|
|
mods.terminal.emulator.enable = true;
|
|
mods.terminal.development.enable = true;
|
|
mods.terminal.tools.enable = true;
|
|
mods.desktop.development.enable = true;
|
|
mods.desktop.productivity.enable = false;
|
|
|
|
# Hardware preferences
|
|
## Monitors
|
|
services.autorandr.enable = true;
|
|
programs.autorandr = {
|
|
enable = true;
|
|
hooks.postswitch = {
|
|
"notify-i3" = "${pkgs.i3}/bin/i3-msg restart";
|
|
"set-wallpaper" = ''
|
|
${lib.getExe pkgs.feh} --bg-fill --nofehbg ${./wallpaper.png}
|
|
'';
|
|
};
|
|
};
|
|
|
|
# Version of first install
|
|
home.stateVersion = "23.05";
|
|
}
|