From 832cd29f9150dc67e5cfa64963a09acdb2699938 Mon Sep 17 00:00:00 2001 From: Alexander Bantyev Date: Tue, 23 Nov 2021 11:33:00 +0300 Subject: [PATCH] Add usb-persist config --- machines/usb-persist/default.nix | 57 +++++++++++++++++++ .../usb-persist/hardware-configuration.nix | 31 ++++++++++ machines/usb-persist/system | 1 + profiles/bluetooth.nix | 13 +++++ profiles/boot.nix | 2 +- profiles/hardware.nix | 27 +-------- profiles/opengl.nix | 6 ++ profiles/power.nix | 7 +++ roles/desktop.nix | 3 + 9 files changed, 120 insertions(+), 27 deletions(-) create mode 100644 machines/usb-persist/default.nix create mode 100644 machines/usb-persist/hardware-configuration.nix create mode 100644 machines/usb-persist/system create mode 100644 profiles/bluetooth.nix create mode 100644 profiles/opengl.nix create mode 100644 profiles/power.nix diff --git a/machines/usb-persist/default.nix b/machines/usb-persist/default.nix new file mode 100644 index 0000000..c17b10a --- /dev/null +++ b/machines/usb-persist/default.nix @@ -0,0 +1,57 @@ +{ lib, inputs, pkgs, config, ... }: { + imports = with inputs.self.nixosModules; with inputs.self.nixosProfiles; [ + ./hardware-configuration.nix + + inputs.self.nixosRoles.base + + themes + fonts + gtk + + sway + i3blocks + himalaya + bluetooth + + simple-osd-daemons + alacritty + firefox + emacs + ]; + + deviceSpecific.devInfo = { + cpu = { + vendor = "intel"; + clock = 2000; + cores = 2; + }; + drive = { + type = "ssd"; + speed = 6000; + size = 16; + }; + bigScreen = false; + ram = 2; + }; + + networking.wireless.enable = lib.mkForce false; + services.openssh.permitRootLogin = lib.mkForce "no"; + services.getty.autologinUser = lib.mkForce "balsoft"; + boot.kernelPackages = lib.mkForce pkgs.linuxPackages_latest; + boot.supportedFilesystems = lib.mkForce [ "ext4" "vfat" ]; + boot.loader.systemd-boot.enable = lib.mkForce false; + boot.loader.grub = { + enable = lib.mkForce true; + devices = [ "/dev/sdc" ]; + }; + persist = { + enable = true; + }; + + defaultApplications = { + monitor.cmd = "${pkgs.alacritty}/bin/alacritty -e top"; + }; + + startupApplications = [ config.defaultApplications.browser.cmd ]; + +} diff --git a/machines/usb-persist/hardware-configuration.nix b/machines/usb-persist/hardware-configuration.nix new file mode 100644 index 0000000..aeed24b --- /dev/null +++ b/machines/usb-persist/hardware-configuration.nix @@ -0,0 +1,31 @@ +# 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 = [ "nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/persist" = + { device = "/dev/disk/by-uuid/315c1e94-7395-4a7e-ada8-40e3409f1a2b"; + fsType = "ext4"; + neededForBoot = true; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/08B0-2766"; + fsType = "vfat"; + }; + + swapDevices = [ ]; + + # high-resolution display + hardware.video.hidpi.enable = lib.mkDefault false; +} diff --git a/machines/usb-persist/system b/machines/usb-persist/system new file mode 100644 index 0000000..9bdfd5f --- /dev/null +++ b/machines/usb-persist/system @@ -0,0 +1 @@ +x86_64-linux \ No newline at end of file diff --git a/profiles/bluetooth.nix b/profiles/bluetooth.nix new file mode 100644 index 0000000..4000340 --- /dev/null +++ b/profiles/bluetooth.nix @@ -0,0 +1,13 @@ +{ pkgs, lib, ... }: { + hardware.bluetooth = { + enable = true; + package = pkgs.bluezFull; + }; + + systemd.services.bluetooth.serviceConfig.ExecStart = lib.mkForce [ + "" + "${pkgs.bluezFull}/libexec/bluetooth/bluetoothd -f /etc/bluetooth/main.conf -E" + ]; + + persist.state.directories = [ "/var/lib/bluetooth" ]; +} diff --git a/profiles/boot.nix b/profiles/boot.nix index 669f785..1cf3a90 100644 --- a/profiles/boot.nix +++ b/profiles/boot.nix @@ -2,7 +2,7 @@ boot = { loader = { timeout = lib.mkForce 4; - grub.enable = lib.mkForce false; + grub.enable = false; systemd-boot.enable = pkgs.system == "x86_64-linux"; }; kernelParams = [ "quiet" "scsi_mod.use_blk_mq=1" "modeset" "nofb" ] diff --git a/profiles/hardware.nix b/profiles/hardware.nix index 5d479b6..ad9358b 100644 --- a/profiles/hardware.nix +++ b/profiles/hardware.nix @@ -1,31 +1,6 @@ -{ pkgs, config, lib, inputs, ... }: - -with rec { inherit (config) device deviceSpecific; }; -with deviceSpecific; { +{ hardware.enableRedistributableFirmware = true; # For some unfree drivers - - hardware.opengl.enable = true; - hardware.opengl.driSupport = true; - hardware.opengl.driSupport32Bit = true; # For steam - hardware.opengl.package = pkgs.mesa_drivers; - - hardware.bluetooth = { - enable = true; - package = pkgs.bluezFull; - }; - - systemd.services.bluetooth.serviceConfig.ExecStart = lib.mkForce [ "" "${pkgs.bluezFull}/libexec/bluetooth/bluetoothd -f /etc/bluetooth/main.conf -E" ]; - - persist.state.directories = [ "/var/lib/bluetooth" ]; - systemd.services.systemd-udev-settle.enable = false; - - services.upower = { enable = true; }; - - services.logind.lidSwitchExternalPower = "ignore"; - - services.logind.extraConfig = "HandlePowerKey=suspend"; - services.fwupd.enable = true; # sound.enable = true; } diff --git a/profiles/opengl.nix b/profiles/opengl.nix new file mode 100644 index 0000000..59b071a --- /dev/null +++ b/profiles/opengl.nix @@ -0,0 +1,6 @@ +{ pkgs, ... }: { + hardware.opengl.enable = true; + hardware.opengl.driSupport = true; + hardware.opengl.driSupport32Bit = true; # For steam + hardware.opengl.package = pkgs.mesa_drivers; +} diff --git a/profiles/power.nix b/profiles/power.nix new file mode 100644 index 0000000..6e2ab2e --- /dev/null +++ b/profiles/power.nix @@ -0,0 +1,7 @@ +{ + services.upower = { enable = true; }; + + services.logind.lidSwitchExternalPower = "ignore"; + + services.logind.extraConfig = "HandlePowerKey=suspend"; +} diff --git a/roles/desktop.nix b/roles/desktop.nix index b80f8e6..377df82 100644 --- a/roles/desktop.nix +++ b/roles/desktop.nix @@ -9,6 +9,9 @@ # PROFILES applications-setup + bluetooth + power + opengl hardware sound virtualisation