Add multi-host configuration

based loosely on https://github.com/tom-on-the-internet/system-configuration
This commit is contained in:
Elnu 2022-10-09 19:09:47 -07:00
parent f554a9038b
commit 8f0f5b9bbf
13 changed files with 254 additions and 240 deletions

39
hosts/configuration.nix Normal file
View file

@ -0,0 +1,39 @@
{ config, pkgs, user, inputs, ... }:
{
# Automatically delete generations older than a week
nix.gc = {
automatic = true;
options = "--delete-generations 8d";
};
networking.networkmanager.enable = true;
time.timeZone = "America/Los_Angeles";
users.users.${user} = {
isNormalUser = true;
extraGroups = [ "wheel" "audio" "video" "optical" "storage" ];
initialPassword = "password";
};
nixpkgs.config.allowUnfree = true;
nix = {
package = pkgs.nixVersions.stable; # flakes
extraOptions = "experimental-features = nix-command flakes";
};
environment.systemPackages = with pkgs; [
rustc
cargo
];
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "22.05"; # Did you read the comment?
}

53
hosts/default.nix Normal file
View file

@ -0,0 +1,53 @@
{ lib, inputs, nixpkgs, home-manager, user, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
lib = nixpkgs.lib;
in
{
elnupad = lib.nixosSystem {
inherit system;
specialArgs = { inherit user; };
modules = [
./elnupad
./configuration.nix
./desktop.nix
home-manager.nixosModules.home-manager {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = { inherit user; };
home-manager.users.${user} = {
imports = [
(import ./home.nix)
(import ./elnupad/home.nix)
];
};
}
];
};
virtualbox = lib.nixosSystem {
inherit system;
specialArgs = { inherit user; };
modules = [
./virtualbox
./configuration.nix
./desktop.nix
home-manager.nixosModules.home-manager {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = { inherit user; };
home-manager.users.${user} = {
imports = [
(import ./home.nix)
(import ./virtualbox/home.nix)
];
};
}
];
};
}

36
hosts/desktop.nix Normal file
View file

@ -0,0 +1,36 @@
{ config, pkgs, ... }:
{
services = {
xserver = {
enable = true;
libinput = {
enable = true;
touchpad = {
naturalScrolling = true;
tapping = true;
};
};
xkbOptions = "caps:escape";
displayManager = {
lightdm.enable = true;
#sddm.enable = true;
defaultSession = "none+i3";
};
windowManager.i3 = {
enable = true;
package = pkgs.i3-gaps;
};
};
};
sound.enable = true;
hardware.pulseaudio.enable = true;
nixpkgs.config.pulseaudio = true;
fonts.fonts = with pkgs; [
noto-fonts
noto-fonts-cjk
(nerdfonts.override { fonts = [ "FiraCode" ]; }) # required for icons
];
}

28
hosts/elnupad/default.nix Normal file
View file

@ -0,0 +1,28 @@
{ ... }:
{
imports = [ (import ./hardware-configuration.nix) ];
boot.loader = {
efi = {
canTouchEfiVariables = true;
efiSysMountPoint = "/boot";
};
grub = {
efiSupport = true;
device = "nodev";
# 1024x768 is the closest supported resolution to X220's native 1366x768
# To see a list of supported GRUB resolutions, enter GRUB,
# press e, F2 to enter command mode, and then type videoinfo to see list
gfxmodeEfi = "1024x768";
};
};
networking.hostName = "elnupad";
time.timeZone = "America/Los_Angeles";
# Use X11 caps lock to escape remap in TTY
console.useXkbConfig = true;
services.xserver.xkbOptions = "caps:escape";
}

View file

@ -0,0 +1,39 @@
# 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 = [ ];
boot.initrd.availableKernelModules = [ "ehci_pci" "ahci" "usb_storage" "sd_mod" "sdhci_pci" ];
boot.kernelPackages = pkgs.linuxPackages_latest;
boot.kernelModules = [ "kvm-intel" "coretemp" ];
boot.extraModulePackages = [ ];
hardware.enableAllFirmware = true;
hardware.enableRedistributableFirmware = true;
fileSystems = {
"/" = {
device = "/dev/disk/by-label/nixos";
fsType = "ext4";
};
"/boot" = {
device = "/dev/disk/by-label/boot";
fsType = "vfat";
};
};
swapDevices = [ ];
# 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.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp0s3.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

3
hosts/elnupad/home.nix Normal file
View file

@ -0,0 +1,3 @@
{ pkgs, ... }: {
}

45
hosts/home.nix Normal file
View file

@ -0,0 +1,45 @@
{ config, pkgs, user, ... }:
{
imports = [
../vim.nix
../wallpaper.nix
../picom.nix
../i3.nix
../polybar
../rofi
../git.nix
../terminal.nix
];
programs.home-manager.enable = true;
home = {
username = "${user}";
homeDirectory = "/home/${user}";
stateVersion = "22.05";
packages = with pkgs; [
# Command line utilities
wget
neofetch
ranger
trash-cli # aliased to rm in .bashrc
# GUI applications
firefox
discord
];
file = {
".bashrc" = {
source = ../.bashrc;
};
};
sessionVariables = {
EDITOR = "vim";
};
};
}

View file

@ -0,0 +1,12 @@
{ config, pkgs, ... }:
{
imports = [ ./hardware-configuration.nix ];
boot.loader.grub = {
enable = true;
device = "/dev/sda";
};
networking.hostName = "virtualbox";
}

View file

@ -0,0 +1,30 @@
# 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 = [ ];
boot.initrd.availableKernelModules = [ "ata_piix" "ohci_pci" "sd_mod" "sr_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-label/nixos";
fsType = "ext4";
};
swapDevices = [ ];
# 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.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp0s3.useDHCP = lib.mkDefault true;
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
virtualisation.virtualbox.guest.enable = true;
}

View file

@ -0,0 +1,3 @@
{ pkgs, ... }: {
}