Initial commit

This commit is contained in:
2025-08-20 18:24:02 +03:00
commit 2dec42d487
116 changed files with 6591 additions and 0 deletions

15
modules/n/aliases.nix Normal file
View File

@@ -0,0 +1,15 @@
{ lib, pkgs, ... }:
with lib; {
options.n.misc.aliases = mkOption {
type = types.attrs;
};
config.n.misc.aliases = {
ls = "${lib.getExe pkgs.lsd} --group-directories-first";
la = "${lib.getExe pkgs.lsd} -l";
cat = "${lib.getExe pkgs.bat}";
dcat = "${lib.getExe pkgs.bat} --plain";
list-generations = "nix-env -p /nix/var/nix/profiles/system --list-generations";
delete-generations = "nix-env -p /nix/var/nix/profiles/system --delete-generations";
myip = "${lib.getExe pkgs.curl} ipwho.de/json | ${lib.getExe pkgs.jq} .";
};
}

42
modules/n/bootloader.nix Normal file
View File

@@ -0,0 +1,42 @@
{ lib, pkgs, config, inputs, ... }:
with lib;
let
cfg = config.n.host.bootloader;
in {
options.n.host.bootloader = mkOption { type = types.str; };
imports = [ inputs.lanzaboote.nixosModules.lanzaboote ];
config = mkMerge [
(mkIf (cfg == "lanzaboote") {
environment.systemPackages = [ pkgs.sbctl ];
boot = {
loader = {
systemd-boot.enable = lib.mkForce false;
grub.enable = lib.mkForce false;
efi.canTouchEfiVariables = true;
};
bootspec.enable = true;
lanzaboote = {
enable = true;
pkiBundle = "/var/lib/sbctl";
};
};
imp.dirs = [ { directory = "/var/lib/sbctl"; mode = "0400"; } ];
})
(mkIf (cfg == "grub") {
boot.loader.grub = {
enable = true;
efiSupport = lib.mkDefault false;
# efiInstallAsRemovable = true; # TODO: what's it?
device = "nodev";
};
boot.loader.systemd-boot.enable = lib.mkForce false;
})
(mkIf (cfg == "sysdboot") {
boot.loader.systemd-boot.enable = true;
})
];
}

23
modules/n/default.nix Normal file
View File

@@ -0,0 +1,23 @@
{ lib, config, pkgs, host, ... }:
with lib;
let
cfg = config.n.host;
in {
options.n.host = {
kernel = mkOption {
type = types.raw;
default = pkgs.linuxKernel.packages.linux_6_1_hardened;
};
users = mkOption { type = with types; attrs; default = {}; };
defaultUser = mkOption { type = type.str; };
extras = mkOption { type = with types; listOf path; };
types = mkOption { type = with types; listOf str; };
};
options.nodes = mkOption { type = with types; attrsOf attrs; };
config = {
boot.kernelPackages = cfg.kernel;
users.users = cfg.users;
};
}

16
modules/n/defaults.nix Normal file
View File

@@ -0,0 +1,16 @@
{ lib, config, ... }:
with lib; { # Thanks to azahi!
options.n.misc.defaults = mkOption {
description = "Default applications.";
type = with types; attrsOf (listOf str);
default = {};
};
config.hm.xdg = {
enable = true;
mimeApps = {
enable = true;
defaultApplications = mkMerge (mapAttrsToList (n: v: genAttrs v (_: [ "${n}.desktop" ])) config.n.misc.defaults);
};
};
}

41
modules/n/hardware.nix Normal file
View File

@@ -0,0 +1,41 @@
{ lib, config, ... }:
with lib;
let
cfg = config.n.host.hardware;
in {
options.n.host.hardware = {
cpu = mkOption { type = types.str; default = ""; };
};
config = mkMerge [
(mkIf (cfg.cpu == "amd")
{
boot.kernelModules = [ "kvm-amd" ];
hardware.cpu.amd.updateMicrocode = true;
}
)
(mkIf (cfg.cpu == "intel")
{
hardware.cpu.intel.updateMicrocode = true;
}
)
(mkIf (cfg.cpu == "virt")
{
boot.initrd.availableKernelModules = [
"virtio_net"
"virtio_pci"
"virtio_mmio"
"virtio_blk"
"virtio_scsi"
"9p"
"9pnet_virtio"
];
boot.initrd.kernelModules = [
"virtio_balloon"
"virtio_console"
"virtio_rng"
"virtio_gpu"
];
}
)
];
}

View File

@@ -0,0 +1,64 @@
{ lib, config, inputs, username, ... }:
with lib;
let
cfg = config.imp;
in {
imports = [
inputs.impermanence.nixosModules.impermanence
(mkAliasOptionModule [ "imp" "dirs" ] [
"environment"
"persistence"
"/nix/persist"
"directories"
])
];
options.imp.home = {
files = mkOption {
type = with types; listOf str;
default = [];
};
dirs = mkOption {
type = with types; listOf str;
default = [];
};
};
config = {
environment.persistence."/nix/persist" = {
enable = true;
directories = [
"/var/lib/systemd/coredump"
"/var/lib/nixos"
];
files = [
"/etc/machine-id"
];
};
environment.persistence."/nix/persist".users."${username}" = {
# environment.persistence."/nix/persist".users."user" = {
directories = builtins.map (x: { directory = x; mode = "0700"; })
[
"Audiobooks"
"Books"
"Desktop"
"Documents"
# "Downloads"
"Extensions"
"Forks"
"Games"
"IdeaProjects"
"Keybase"
"Library"
"Monero"
"Music"
"Phone"
"Pictures"
"Projects"
"Videos"
] ++ cfg.home.dirs;
files = builtins.map (x: { file = x; parentDirectory = { mode = "0700"; }; }) cfg.home.files;
};
};
}

22
modules/n/networking.nix Normal file
View File

@@ -0,0 +1,22 @@
{ host, lib, config, ... }:
with lib;
let cfg = config.n.host;
in {
options.n.host = {
hostId = mkOption { type = types.str; };
domain = mkOption { type = types.str; default = "${host}.local"; };
};
config = {
networking = {
hostName = host;
hostId = cfg.hostId;
domain = cfg.domain;
dhcpcd.enable = true;
useDHCP = lib.mkDefault true;
};
systemd.network.wait-online.enable = lib.mkForce false;
boot.initrd.systemd.network.wait-online.enable = lib.mkForce false;
systemd.services.NetworkManager-wait-online.enable = lib.mkForce false;
};
}

13
modules/n/unfree.nix Normal file
View File

@@ -0,0 +1,13 @@
{ lib, config, ... }:
with lib;
let
cfg = config.n.misc.unfreePackages;
in {
options.n.misc.unfreePackages = mkOption {
type = with types; listOf str;
};
config = {
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) cfg;
};
}