From 4d55dc2764c6f95806cbc7a0ac2f176b812264c5 Mon Sep 17 00:00:00 2001 From: janabhumi Date: Sun, 4 Sep 2022 16:04:28 +0300 Subject: [PATCH] system/usb: add config for usb stick --- outputs/system.nix | 7 +++ system/machine/usb-stick/default.nix | 59 +++++++++++++++++++ .../usb-stick/hardware-configuration.nix | 47 +++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 system/machine/usb-stick/default.nix create mode 100644 system/machine/usb-stick/hardware-configuration.nix diff --git a/outputs/system.nix b/outputs/system.nix index b50702f..de62cc2 100644 --- a/outputs/system.nix +++ b/outputs/system.nix @@ -10,4 +10,11 @@ with inputs; ../system/machine/home ]; }; + usbStick = nixpkgs.lib.nixosSystem { + inherit system; + modules = [ + ../system/configuration.nix + ../system/machine/usb-stick + ]; + }; } diff --git a/system/machine/usb-stick/default.nix b/system/machine/usb-stick/default.nix new file mode 100644 index 0000000..4784e4d --- /dev/null +++ b/system/machine/usb-stick/default.nix @@ -0,0 +1,59 @@ +{ config, pkgs, lib, ... }: + +{ + imports = [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + boot = { + # Use the GRUB 2 boot loader. + loader.grub = { + enable = true; + device = "/dev/disk/by-uuid/8e7c22c5-5c88-47a1-becf-6dbf05f4067d"; + }; + + kernelPackages = pkgs.linuxPackages_latest; + extraModulePackages = with config.boot.kernelPackages; [ + rtl88x2bu + ]; + }; + + networking = { + hostName = "usb-stick"; # Define your hostname. + + interfaces = { + enp3s0.useDHCP = true; + wlp11s0f3u2.useDHCP = true; + }; + }; + + environment.systemPackages = with pkgs; [ parted ]; + + services.xserver = { + # All monitors in the right order + # Source: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/x11/xserver.nix#L83 + xrandrHeads = [ + { + output = "HDMI-A-0"; + monitorConfig = '' + Option "PreferredMode" "1920x1080" + Option "Rotate" "right" + ''; + } + { + output = "DisplayPort-1"; + primary = true; + monitorConfig = '' + Option "PreferredMode" "2560x1440" + ''; + } + ]; + }; + + sound.enable = lib.mkForce false; + + programs.gnupg.agent.enable = lib.mkForce false; + virtualisation.docker.enable = lib.mkForce false; + nix.gc.automatic = lib.mkForce false; +} diff --git a/system/machine/usb-stick/hardware-configuration.nix b/system/machine/usb-stick/hardware-configuration.nix new file mode 100644 index 0000000..5fba1b7 --- /dev/null +++ b/system/machine/usb-stick/hardware-configuration.nix @@ -0,0 +1,47 @@ +# 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 = [ "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems = { + "/" = { + device = "/dev/disk/by-uuid/2e6b4520-dd52-4593-afb4-bd585bd1215c"; + fsType = "ext4"; + }; + + "/home" = { + device = "/dev/disk/by-uuid/e17fb0c0-9482-436d-83e8-3760772fe9b8"; + fsType = "ext4"; + }; + }; + + swapDevices = [ + { device = "/dev/disk/by-uuid/ca4a3ef2-1428-4021-9b67-464fb2e2b7a7"; } + ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.br-dd3908647dce.useDHCP = lib.mkDefault true; + # networking.interfaces.docker0.useDHCP = lib.mkDefault true; + # networking.interfaces.enp3s0.useDHCP = lib.mkDefault true; + # networking.interfaces.vethca7bcf0.useDHCP = lib.mkDefault true; + # networking.interfaces.vethcaab0c1.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp11s0f3u2.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +}