Added nix files
This commit is contained in:
parent
bf0779ae97
commit
5965d43eff
37
flake.nix
Normal file
37
flake.nix
Normal file
@ -0,0 +1,37 @@
|
||||
outputs = { nixpkgs, home-manager, ... }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
in {
|
||||
nixosConfigurations = {
|
||||
laptop = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
./hosts/laptop.nix
|
||||
./modules/common.nix
|
||||
./modules/hyprland.nix
|
||||
./modules/networking.nix
|
||||
./modules/user.nix
|
||||
];
|
||||
};
|
||||
desktop = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
./hosts/desktop.nix
|
||||
./modules/common.nix
|
||||
./modules/hyprland.nix
|
||||
./modules/networking.nix
|
||||
./modules/user.nix
|
||||
];
|
||||
};
|
||||
vm = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
./hosts/vm.nix
|
||||
./modules/common.nix
|
||||
./modules/hyprland.nix
|
||||
./modules/networking.nix
|
||||
./modules/user.nix
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
28
hosts/desktop.nix
Normal file
28
hosts/desktop.nix
Normal file
@ -0,0 +1,28 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
networking.hostName = "desktop";
|
||||
|
||||
# NVIDIA proprietary drivers
|
||||
services.xserver.videoDrivers = [ "nvidia" ];
|
||||
|
||||
hardware.nvidia = {
|
||||
modesetting.enable = true;
|
||||
open = false;
|
||||
nvidiaSettings = true;
|
||||
};
|
||||
|
||||
boot.initrd.luks.devices = {
|
||||
root = {
|
||||
device = "/dev/sda2";
|
||||
preLVM = true;
|
||||
};
|
||||
};
|
||||
|
||||
# Dual display configuration
|
||||
services.xserver = {
|
||||
screenSection = ''
|
||||
Option "metamodes" "HDMI-0: 1920x1080 +0+0, DP-0: 1920x1080 +1920+0"
|
||||
'';
|
||||
};
|
||||
}
|
24
hosts/laptop.nix
Normal file
24
hosts/laptop.nix
Normal file
@ -0,0 +1,24 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
networking.hostName = "laptop";
|
||||
|
||||
# Intel VA-API for GPU acceleration
|
||||
hardware.opengl = {
|
||||
enable = true;
|
||||
driSupport = true;
|
||||
extraPackages = with pkgs; [
|
||||
intel-media-driver
|
||||
libva-utils
|
||||
];
|
||||
};
|
||||
|
||||
boot.initrd.luks.devices = {
|
||||
root = {
|
||||
device = "/dev/sda2";
|
||||
preLVM = true;
|
||||
};
|
||||
};
|
||||
|
||||
services.xserver.videoDrivers = [ "intel" ];
|
||||
}
|
32
hosts/vm.nix
Normal file
32
hosts/vm.nix
Normal file
@ -0,0 +1,32 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
networking.hostName = "vm";
|
||||
|
||||
# Use DHCP for networking
|
||||
networking.useDHCP = true;
|
||||
|
||||
# Disk encryption setup
|
||||
boot.initrd.luks.devices = {
|
||||
root = {
|
||||
device = "/dev/sda2";
|
||||
preLVM = true;
|
||||
};
|
||||
};
|
||||
|
||||
# Hyprland setup without GPU acceleration
|
||||
services.xserver.enable = true;
|
||||
services.xserver.videoDrivers = [ ];
|
||||
|
||||
# Use the same package set as desktop/laptop
|
||||
environment.systemPackages = with pkgs; [
|
||||
alacritty
|
||||
brave
|
||||
helix
|
||||
rustc cargo
|
||||
go
|
||||
nodejs
|
||||
discord
|
||||
spotify
|
||||
];
|
||||
}
|
23
install.sh
Normal file
23
install.sh
Normal file
@ -0,0 +1,23 @@
|
||||
# Assuming /dev/sda is the target disk
|
||||
parted /dev/sda -- mklabel gpt
|
||||
parted /dev/sda -- mkpart primary ext4 1MiB 100%
|
||||
mkfs.ext4 /dev/sda2
|
||||
mount /dev/sda2 /mnt
|
||||
|
||||
cryptsetup luksFormat /dev/sda2
|
||||
cryptsetup open /dev/sda2 root
|
||||
mkfs.ext4 /dev/mapper/root
|
||||
mount /dev/mapper/root /mnt
|
||||
|
||||
mkdir -p /mnt/etc/nixos
|
||||
git clone https://git.luke-else.co.uk/luke-else/nixos-config.git /mnt/etc/nixos
|
||||
|
||||
nixos-generate-config --root /mnt
|
||||
|
||||
nixos-install --flake /mnt/etc/nixos#vm
|
||||
|
||||
passwd
|
||||
|
||||
reboot
|
||||
|
||||
# sudo nixos-rebuild switch --flake ~/nixos-config#vm
|
35
modules/common.nix
Normal file
35
modules/common.nix
Normal file
@ -0,0 +1,35 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
# Bootloader
|
||||
boot.loader.grub = {
|
||||
enable = true;
|
||||
version = 2;
|
||||
device = "nodev";
|
||||
efiSupport = true;
|
||||
};
|
||||
|
||||
fileSystems."/" = {
|
||||
device = "/dev/mapper/root";
|
||||
fsType = "ext4";
|
||||
};
|
||||
|
||||
swapDevices = [{ device = "/swapfile"; size = 4096; }];
|
||||
|
||||
# Locales and timezone
|
||||
time.timeZone = "Europe/London";
|
||||
i18n.defaultLocale = "en_GB.UTF-8";
|
||||
|
||||
# UFW Firewall
|
||||
networking.firewall = {
|
||||
enable = true;
|
||||
allowedTCPPorts = [ 22 ]; # Allow SSH
|
||||
};
|
||||
|
||||
# Enable SSH
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
permitRootLogin = "no";
|
||||
passwordAuthentication = false;
|
||||
};
|
||||
}
|
25
modules/hyprland.nix
Normal file
25
modules/hyprland.nix
Normal file
@ -0,0 +1,25 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
programs.hyprland = {
|
||||
enable = true;
|
||||
xwayland.enable = true;
|
||||
};
|
||||
|
||||
services.displayManager = {
|
||||
enable = true;
|
||||
defaultSession = "hyprland";
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
alacritty # Terminal
|
||||
brave # Browser
|
||||
helix # Text editor
|
||||
rustc cargo # Rust
|
||||
go # Go
|
||||
nodejs # Node.js
|
||||
discord
|
||||
spotify
|
||||
bitwarden
|
||||
];
|
||||
}
|
15
modules/networking.nix
Normal file
15
modules/networking.nix
Normal file
@ -0,0 +1,15 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
networking = {
|
||||
wireless = {
|
||||
enable = true;
|
||||
networks = {
|
||||
"your-SSID" = {
|
||||
psk = "your-wifi-password";
|
||||
};
|
||||
};
|
||||
};
|
||||
dhcp = true;
|
||||
};
|
||||
}
|
15
modules/user.nix
Normal file
15
modules/user.nix
Normal file
@ -0,0 +1,15 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
users.users."luke-else" = {
|
||||
isNormalUser = true;
|
||||
home = "/home/luke-else";
|
||||
shell = pkgs.bash;
|
||||
extraGroups = [ "wheel" "networkmanager" "docker" ];
|
||||
};
|
||||
|
||||
security.sudo = {
|
||||
enable = true;
|
||||
wheelNeedsPassword = true;
|
||||
};
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user