102
hosts/common/core/default.nix
Normal file
102
hosts/common/core/default.nix
Normal file
@@ -0,0 +1,102 @@
|
||||
{
|
||||
pkgs,
|
||||
inputs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
imports = lib.flatten [
|
||||
inputs.home-manager.nixosModules.home-manager
|
||||
inputs.sops-nix.nixosModules.sops
|
||||
|
||||
(map lib.custom.relativeToRoot [
|
||||
"modules/common"
|
||||
"hosts/common/users/primary"
|
||||
])
|
||||
];
|
||||
|
||||
hostSpec = {
|
||||
username = "shahab";
|
||||
handle = "shahab96";
|
||||
email = {
|
||||
user = "shahab@dogar.dev";
|
||||
};
|
||||
userFullName = "Shahab Dogar";
|
||||
domain = "rihla";
|
||||
networking.ports.tcp.ssh = 22;
|
||||
};
|
||||
|
||||
networking.hostName = config.hostSpec.hostName;
|
||||
|
||||
home-manager = {
|
||||
useGlobalPkgs = true;
|
||||
backupFileExtension = "bk";
|
||||
};
|
||||
|
||||
#
|
||||
# ========= Overlays =========
|
||||
#
|
||||
nixpkgs = {
|
||||
config = {
|
||||
allowUnfree = true;
|
||||
allowUnfreePredicate = _: true;
|
||||
};
|
||||
};
|
||||
|
||||
#
|
||||
# ========= Nix Settings =========
|
||||
#
|
||||
nix = {
|
||||
settings = {
|
||||
# See https://jackson.dev/post/nix-reasonable-defaults/
|
||||
connect-timeout = 5;
|
||||
log-lines = 25;
|
||||
min-free = 128000000; # 128MB
|
||||
max-free = 1000000000; # 1GB
|
||||
|
||||
auto-optimise-store = true;
|
||||
warn-dirty = false;
|
||||
trusted-users = [ "@wheel" ];
|
||||
|
||||
substituters = ["https://hyprland.cachix.org"];
|
||||
trusted-public-keys = ["hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="];
|
||||
experimental-features = [
|
||||
"nix-command"
|
||||
"flakes"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
# ========== Nix Helper ==========
|
||||
# Provide better build output and will also handle garbage collection in place of standard nix gc (garbace collection)
|
||||
programs.nh = {
|
||||
enable = true;
|
||||
clean.enable = true;
|
||||
clean.extraArgs = "--keep-since 10d --keep 10";
|
||||
flake = "/home/user/${config.hostSpec.home}/nix-config";
|
||||
};
|
||||
|
||||
# ========= Sops =========
|
||||
environment.systemPackages = with pkgs; [
|
||||
sops
|
||||
];
|
||||
|
||||
#
|
||||
# ========== Localization ==========
|
||||
#
|
||||
i18n.defaultLocale = lib.mkDefault "en_US.UTF-8";
|
||||
i18n.extraLocaleSettings = {
|
||||
LC_ADDRESS = "ur_PK";
|
||||
LC_IDENTIFICATION = "ur_PK";
|
||||
LC_MEASUREMENT = "ur_PK";
|
||||
LC_MONETARY = "ur_PK";
|
||||
LC_NAME = "ur_PK";
|
||||
LC_NUMERIC = "ur_PK";
|
||||
LC_PAPER = "ur_PK";
|
||||
LC_TELEPHONE = "ur_PK";
|
||||
LC_TIME = "ur_PK";
|
||||
};
|
||||
time.timeZone = lib.mkDefault "Asia/Karachi";
|
||||
}
|
||||
100
hosts/common/disks/rihla.nix
Normal file
100
hosts/common/disks/rihla.nix
Normal file
@@ -0,0 +1,100 @@
|
||||
{
|
||||
disko = {
|
||||
devices = {
|
||||
disk = {
|
||||
main = {
|
||||
device = "/dev/nvme0n1";
|
||||
type = "disk";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
boot = {
|
||||
name = "boot";
|
||||
size = "1M";
|
||||
type = "EF02";
|
||||
};
|
||||
esp = {
|
||||
name = "ESP";
|
||||
size = "500M";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
};
|
||||
luks = {
|
||||
size = "100%";
|
||||
content = {
|
||||
name = "crypted";
|
||||
type = "luks";
|
||||
passwordFile = "/tmp/secret.key";
|
||||
settings = {
|
||||
allowDiscards = true;
|
||||
crypttabExtraOpts = [
|
||||
"fido2-device=auto"
|
||||
"token-timeout=10"
|
||||
];
|
||||
};
|
||||
content = {
|
||||
type = "lvm_pv";
|
||||
vg = "crypt_vg";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
lvm_vg = {
|
||||
crypt_vg = {
|
||||
type = "lvm_vg";
|
||||
lvs = {
|
||||
swap = {
|
||||
size = "64G";
|
||||
content = {
|
||||
type = "swap";
|
||||
resumeDevice = true;
|
||||
};
|
||||
};
|
||||
main = {
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "btrfs";
|
||||
extraArgs = [
|
||||
"-L"
|
||||
"nixos"
|
||||
"-f"
|
||||
];
|
||||
subvolumes = {
|
||||
"@root" = {
|
||||
mountpoint = "/";
|
||||
mountOptions = [
|
||||
"compress=zstd"
|
||||
];
|
||||
};
|
||||
"@home" = {
|
||||
mountpoint = "/home";
|
||||
mountOptions = [
|
||||
"subvol=home"
|
||||
"compress=zstd"
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
"@nix" = {
|
||||
mountpoint = "/nix";
|
||||
mountOptions = [
|
||||
"subvol=nix"
|
||||
"compress=zstd"
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
14
hosts/common/optional/1password.nix
Normal file
14
hosts/common/optional/1password.nix
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
config,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
programs = {
|
||||
_1password.enable = true;
|
||||
_1password-gui = {
|
||||
enable = true;
|
||||
polkitPolicyOwners = [ config.hostSpec.username ];
|
||||
};
|
||||
};
|
||||
}
|
||||
7
hosts/common/optional/dconf.nix
Normal file
7
hosts/common/optional/dconf.nix
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
programs.dconf.enable = true;
|
||||
}
|
||||
47
hosts/common/optional/docker.nix
Normal file
47
hosts/common/optional/docker.nix
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
virtualisation = {
|
||||
podman = {
|
||||
enable = true;
|
||||
dockerSocket.enable = true;
|
||||
dockerCompat = true;
|
||||
|
||||
autoPrune = {
|
||||
enable = true;
|
||||
dates = "weekly";
|
||||
};
|
||||
};
|
||||
|
||||
containers = {
|
||||
registries = {
|
||||
search = ["docker.io"];
|
||||
};
|
||||
};
|
||||
|
||||
libvirtd = {
|
||||
enable = true;
|
||||
qemu = {
|
||||
swtpm.enable = true;
|
||||
|
||||
ovmf = {
|
||||
enable = true;
|
||||
packages = with pkgs; [OVMFFull.fd];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
spiceUSBRedirection.enable = true;
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
virt-manager
|
||||
virt-viewer
|
||||
spice
|
||||
spice-gtk
|
||||
spice-protocol
|
||||
win-virtio
|
||||
win-spice
|
||||
];
|
||||
}
|
||||
22
hosts/common/optional/gaming.nix
Normal file
22
hosts/common/optional/gaming.nix
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
programs = {
|
||||
steam = {
|
||||
enable = true;
|
||||
gamescopeSession.enable = true;
|
||||
};
|
||||
|
||||
# to run steam games in game mode, add the following to the game's properties from within steam
|
||||
# gamemoderun %command%
|
||||
gamemode.enable = true;
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
mangohud
|
||||
protonup-qt
|
||||
];
|
||||
}
|
||||
24
hosts/common/optional/hyprland.nix
Normal file
24
hosts/common/optional/hyprland.nix
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
inputs,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
programs.hyprland = {
|
||||
enable = true;
|
||||
package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland;
|
||||
portalPackage =
|
||||
inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-hyprland;
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
hyprshot
|
||||
hyprlock
|
||||
hypridle
|
||||
hyprpolkitagent
|
||||
mako
|
||||
waybar
|
||||
wofi
|
||||
];
|
||||
}
|
||||
7
hosts/common/optional/nix-ld.nix
Normal file
7
hosts/common/optional/nix-ld.nix
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
programs.nix-ld.enable = true;
|
||||
}
|
||||
10
hosts/common/optional/secure-boot.nix
Normal file
10
hosts/common/optional/secure-boot.nix
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
environment.systemPackages = with pkgs; [
|
||||
sbctl
|
||||
];
|
||||
}
|
||||
23
hosts/common/optional/services/audio.nix
Normal file
23
hosts/common/optional/services/audio.nix
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
services = {
|
||||
# Enable sound with pipewire.
|
||||
pulseaudio.enable = false;
|
||||
pipewire = {
|
||||
enable = true;
|
||||
alsa.enable = true;
|
||||
alsa.support32Bit = true;
|
||||
pulse.enable = true;
|
||||
wireplumber.enable = true;
|
||||
};
|
||||
};
|
||||
security.rtkit.enable = true;
|
||||
|
||||
environment.systemPackages = builtins.attrValues {
|
||||
inherit (pkgs) pavucontrol;
|
||||
};
|
||||
}
|
||||
11
hosts/common/optional/services/bluetooth.nix
Normal file
11
hosts/common/optional/services/bluetooth.nix
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
services.blueman.enable = true;
|
||||
hardware = {
|
||||
bluetooth.enable = true;
|
||||
bluetooth.powerOnBoot = true;
|
||||
};
|
||||
}
|
||||
7
hosts/common/optional/services/firmware.nix
Normal file
7
hosts/common/optional/services/firmware.nix
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
services.fwupd.enable = true;
|
||||
}
|
||||
16
hosts/common/optional/services/greetd.nix
Normal file
16
hosts/common/optional/services/greetd.nix
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
services.greetd = {
|
||||
enable = true;
|
||||
settings = {
|
||||
default_session = {
|
||||
command = "${pkgs.greetd.tuigreet}/bin/tuigreet --greeting 'Welcome to NixOS!' --asterisks --remember --remember-user-session --time --cmd ${pkgs.hyprland}/bin/Hyprland";
|
||||
user = "greeter";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
15
hosts/common/optional/services/openssh.nix
Normal file
15
hosts/common/optional/services/openssh.nix
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
sshPort = config.hostSpec.networking.ports.tcp.ssh;
|
||||
in
|
||||
{
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
ports = [ sshPort ];
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ sshPort ];
|
||||
}
|
||||
8
hosts/common/optional/services/printing.nix
Normal file
8
hosts/common/optional/services/printing.nix
Normal file
@@ -0,0 +1,8 @@
|
||||
# Reminder that CUPS cpanel defaults to localhost:631
|
||||
{
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
services.printing.enable = true;
|
||||
}
|
||||
7
hosts/common/optional/services/smart-card.nix
Normal file
7
hosts/common/optional/services/smart-card.nix
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
services.pcscd.enable = true;
|
||||
}
|
||||
22
hosts/common/optional/yubikey.nix
Normal file
22
hosts/common/optional/yubikey.nix
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
# yubikey login / sudo
|
||||
security.pam = {
|
||||
u2f = {
|
||||
enable = true;
|
||||
settings.cue = true;
|
||||
};
|
||||
services = {
|
||||
login.u2fAuth = true;
|
||||
sudo.u2fAuth = true;
|
||||
};
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
yubikey-manager
|
||||
];
|
||||
}
|
||||
53
hosts/common/users/primary/default.nix
Normal file
53
hosts/common/users/primary/default.nix
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
inputs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
hostSpec = config.hostSpec;
|
||||
pubKeys = lib.filesystem.listFilesRecursive ./keys;
|
||||
in {
|
||||
users = {
|
||||
mutableUsers = false;
|
||||
users.${hostSpec.username} = {
|
||||
# Only do this if you have already configured zsh in home manager
|
||||
ignoreShellProgramCheck = true;
|
||||
|
||||
name = hostSpec.username;
|
||||
shell = pkgs.zsh;
|
||||
home = hostSpec.home;
|
||||
isNormalUser = true;
|
||||
hashedPassword = "$y$j9T$pvjyL7hL5x2VBarGNTnMl1$mLA2UsWTbfp8Hgp/ug5l8224thi..Mo8.p7ME.tDZ.4";
|
||||
extraGroups = [
|
||||
"networkmanager"
|
||||
"wheel"
|
||||
"input"
|
||||
"libvirtd"
|
||||
];
|
||||
|
||||
# Read all keys in ./keys and add them to authorizedKeys.
|
||||
openssh.authorizedKeys.keys = lib.lists.forEach pubKeys (key: builtins.readFile key);
|
||||
|
||||
packages = with pkgs; [
|
||||
libnotify
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
home-manager = {
|
||||
extraSpecialArgs = {
|
||||
inherit pkgs inputs;
|
||||
hostSpec = config.hostSpec;
|
||||
};
|
||||
users.${hostSpec.username}.imports = lib.flatten [
|
||||
(
|
||||
{ config, ... }:
|
||||
import (lib.custom.relativeToRoot "home/${hostSpec.username}/${hostSpec.hostName}.nix") {
|
||||
inherit pkgs inputs config lib hostSpec;
|
||||
}
|
||||
)
|
||||
];
|
||||
};
|
||||
}
|
||||
1
hosts/common/users/primary/keys/id_dogar.pub
Normal file
1
hosts/common/users/primary/keys/id_dogar.pub
Normal file
@@ -0,0 +1 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPBijtTtb6UT5gssWolNGX1rcjAKsdtfz25fZMMnzq4v
|
||||
1
hosts/common/users/primary/keys/id_rihla.pub
Normal file
1
hosts/common/users/primary/keys/id_rihla.pub
Normal file
@@ -0,0 +1 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGD/V4jLpuk7uAovkbHFr6uulfBKZmsH+BqmXIR2aYD0
|
||||
Reference in New Issue
Block a user