From fc3ceedd4efee0e91c0608b8a99ef79220c14fa7 Mon Sep 17 00:00:00 2001 From: klarkc Date: Sat, 8 Jul 2023 20:24:03 -0300 Subject: [PATCH] feat(recover): add gparted --- .gitignore | 1 + flake.nix | 19 ++++++++++--------- recover.nix | 48 ++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 53 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index c4a847d..f3b12c3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /result +/*.img diff --git a/flake.nix b/flake.nix index 15b09d1..84426a5 100644 --- a/flake.nix +++ b/flake.nix @@ -33,26 +33,26 @@ }; # TODO: find a faster way to run recover in devShell - recover-vm = pkgs.writeShellApplication { + mk-recover-vm = args: pkgs.writeShellApplication { name = "recover-vm"; text = '' - TMPD=$(mktemp -d) - echo "$TMPD" - IMG="$TMPD/recover-efi.img" - BIOS="$TMPD/recover-efi-bios.img" + IMG="recover-efi.img" + BIOS="recover-efi-bios.img" + ARGS="${args}" cp -ui --reflink=auto ${pkgs.OVMF.fd}/FV/OVMF.fd "$BIOS" chmod a+w "$BIOS" cp -ui --reflink=auto ${recover-efi}/nixos.img "$IMG" chmod a+w "$IMG" qemu-system-${platform} \ - -nographic \ -bios "$BIOS" \ -drive file="$IMG",format=raw \ - -m 2G - rm -Rf "$TMPD" + -m 2G \ + $ARGS ''; runtimeInputs = with pkgs; [ tree rsync qemu ]; }; + recover-vm = mk-recover-vm ""; + recover-kvm = mk-recover-vm "--enable-kvm"; in { nixosConfigurations = { @@ -60,7 +60,7 @@ }; packages.${system} = { - inherit recover-efi recover-vm; + inherit recover-efi recover-vm recover-kvm; }; devShells.${system}.default = @@ -69,6 +69,7 @@ packages = [ recover-vm + recover-kvm ]; }; diff --git a/recover.nix b/recover.nix index da44b91..2fef553 100644 --- a/recover.nix +++ b/recover.nix @@ -1,15 +1,32 @@ { lib, pkgs, ... }: { - hardware.enableAllFirmware = true; + nix = { + extraOptions = '' + experimental-features = nix-command flakes repl-flake + ''; + }; nixpkgs.config.allowUnfree = true; + hardware.enableAllFirmware = true; users = { - users.root.password = "root"; + users.recover = { + password = "recover"; + isNormalUser = true; + home = "/home/recover"; + description = "Recover"; + extraGroups = [ "wheel" "networkmanager" ]; + }; mutableUsers = false; }; networking = { - hostName = "recover"; + hostName = "recover-os"; networkmanager.enable = true; }; boot = { + kernelParams = [ + "copytoram" + "console=ttyS0,115200" + "console=tty1" + "boot.shell_on_fail" + ]; supportedFilesystems = [ "btrfs" "exfat" @@ -61,11 +78,30 @@ wget which zip + ntfs3g + f2fs-tools + jfsutils + nilfs-utils + reiserfsprogs + xfsprogs + xfsdump + gparted ]; - services.openssh = { - enable = true; - settings.PermitRootLogin = "yes"; + services = { + openssh.enable = true; + + xserver = { + enable = true; + windowManager.xmonad.enable = true; + displayManager = { + defaultSession = "none+xmonad"; + autoLogin = { + enable = true; + user = "recover"; + }; + }; + }; }; programs = {