some changes

This commit is contained in:
tx0 2025-03-14 16:40:36 +00:00
parent 0d25462616
commit 1c543e97f0
79 changed files with 474 additions and 200 deletions

View file

@ -13,31 +13,21 @@
''; '';
outputs = {self, ...} @ inputs: let outputs = {self, ...} @ inputs:
system = "x86_64-linux";
in
inputs.flake-parts.lib.mkFlake {inherit inputs;} { inputs.flake-parts.lib.mkFlake {inherit inputs;} {
flake = let flake = let
machineConf = import ./machines/earth/earth.nix {inherit self;};
system = machineConf.universe.system.arch;
u = import ./ulib {inherit inputs system;}; u = import ./ulib {inherit inputs system;};
in { in {
nixosConfigurations."earth" = inputs.nixpkgs.lib.nixosSystem { nixosConfigurations."earth" = inputs.nixpkgs.lib.nixosSystem {
specialArgs = {inherit system inputs u;}; specialArgs = {inherit system inputs u;};
modules = [ modules = [
./hosts/common machineConf
./hosts/earth ./modules
# universe ./home
./host
inputs.home-manager.nixosModules.home-manager inputs.home-manager.nixosModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
backupFileExtension = "hm-old";
users.tx0 = import ./home;
extraSpecialArgs = {inherit system inputs u;};
};
nixpkgs.overlays = [(import ./overlays/spotx.nix)];
}
]; ];
}; };
}; };

View file

@ -1,16 +1,15 @@
{u, ...}: { {
imports = u.umport { config,
path = ./.; system,
inputs,
include = [ u,
./system/packages/default.nix ...
./programs/graphical/waybar/default.nix }: {
]; home-manager = {
useGlobalPkgs = true;
exclude = [ useUserPackages = true;
./default.nix backupFileExtension = "hm-old";
./system/packages users.${config.universe.system.username} = import ./users/${config.universe.system.username};
./programs/graphical/waybar extraSpecialArgs = {inherit system inputs u;};
];
}; };
} }

View file

@ -0,0 +1,16 @@
{u, ...}: {
imports = u.umport {
path = ./.;
include = [
./system/packages/default.nix
./programs/graphical/waybar/default.nix
];
exclude = [
./default.nix
./system/packages
./programs/graphical/waybar
];
};
}

View file

@ -0,0 +1,13 @@
{config, pkgs,...}: {
programs.zed-editor = {
enable = true;
extensions = [
"nix"
"pylsp"
];
userSettings = {
"buffer_font_size" = config.stylix.fonts.sizes.terminal * 4.0 / 3.0;
};
extraPackages = with pkgs; [nil nixd];
};
}

View file

@ -7,7 +7,7 @@
theme.stylix = { theme.stylix = {
base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-material-dark-medium.yaml"; base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-material-dark-medium.yaml";
# base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-mocha.yaml"; # base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-mocha.yaml";
wallpapers = ../wallpaper.png; wallpapers = ./wallpaper.png;
useLutgen = true; useLutgen = true;
}; };
}; };

View file

Before

Width:  |  Height:  |  Size: 2.6 MiB

After

Width:  |  Height:  |  Size: 2.6 MiB

View file

@ -0,0 +1,9 @@
{
lib,
config,
...
}: {
config = lib.mkIf config.universe.programs.amnezia-vpn.enable {
programs.amnezia-vpn.enable = true;
};
}

View file

@ -0,0 +1,15 @@
{
inputs,
system,
lib,
config,
...
}: {
config = lib.mkIf config.universe.de.hyprland.enable {
programs.hyprland = {
enable = true;
package = inputs.hyprland.packages.${system}.hyprland;
portalPackage = inputs.hyprland.packages.${system}.xdg-desktop-portal-hyprland;
};
};
}

View file

@ -0,0 +1,12 @@
{
inputs,
system,
config,
lib,
...
}: {
config = lib.mkIf config.universe.services.command-not-found.enable {
programs.command-not-found.enable = true;
programs.command-not-found.dbPath = inputs.programsdb.packages.${system}.programs-sqlite;
};
}

View file

@ -0,0 +1,9 @@
{
lib,
config,
...
}: {
config = lib.mkIf config.universe.services.libvirtd.enable {
virtualisation.libvirtd.enable = true;
};
}

17
host/services/openssh.nix Normal file
View file

@ -0,0 +1,17 @@
{
lib,
config,
...
}: let
cfg = config.universe.services.openssh;
in {
config = lib.mkIf cfg.enable {
services.openssh = {
enable = true;
ports = cfg.ports;
settings = {
PasswordAuthentication = false;
};
};
};
}

12
host/services/podman.nix Normal file
View file

@ -0,0 +1,12 @@
{
lib,
config,
...
}: {
config = lib.mkIf config.universe.services.podman.enable {
virtualisation.podman = {
enable = true;
dockerCompat = true;
};
};
}

13
host/services/udev.nix Normal file
View file

@ -0,0 +1,13 @@
{
config,
pkgs,
...
}: {
services.udev.packages =
[]
++ (
if config.universe.programs.android-tools.enable
then [pkgs.android-udev-rules]
else []
);
}

44
host/services/vpn.nix Normal file
View file

@ -0,0 +1,44 @@
{
lib,
config,
inputs,
pkgs,
...
}: let
cfg = config.universe.services.amneziawg;
in {
imports = [
inputs.sops-nix.nixosModules.sops
];
config = lib.mkIf cfg.enable {
sops = {
age.keyFile = "/home/tx0/.age-key.txt";
secrets."${cfg.IfName}.conf" = {
format = "binary";
sopsFile = cfg.secret-config;
path = "/run/secrets.d/{IfName}.conf";
restartUnits = ["awg-${cfg.IfName}.service"];
};
};
systemd.services."awg-${cfg.IfName}" = {
enable = true;
description = "AmneziaWG Interface awg0";
after = ["network.target"];
wantedBy = ["multi-user.target"];
unitConfig = {
ConditionPathExists = "/run/secrets.d/${cfg.IfName}.conf";
};
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStart = "${pkgs.amneziawg-tools}/bin/awg-quick up /run/secrets.d/${cfg.IfName}.conf";
ExecStop = "${pkgs.amneziawg-tools}/bin/awg-quick down /run/secrets.d/${cfg.IfName}.conf";
Restart = "on-failure";
};
};
};
}

View file

@ -6,7 +6,7 @@
}: { }: {
boot = { boot = {
kernelPackages = pkgs.linuxPackages_zen; kernelPackages = pkgs.linuxPackages_zen;
kernelModules = ["i2c-dev" "ddcci_backlight"]; kernelModules = ["i2c-dev"];
extraModulePackages = with config.boot.kernelPackages; [ extraModulePackages = with config.boot.kernelPackages; [
amneziawg amneziawg
]; ];

View file

@ -2,7 +2,6 @@
config, config,
lib, lib,
modulesPath, modulesPath,
system,
... ...
}: { }: {
imports = [ imports = [
@ -56,7 +55,6 @@
}; };
services.xserver.videoDrivers = ["displaylink" "modesetting" "amdgpu"]; services.xserver.videoDrivers = ["displaylink" "modesetting" "amdgpu"];
virtualisation.vmware.host.enable = true;
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
} }

4
host/system/locale.nix Normal file
View file

@ -0,0 +1,4 @@
{config, ...}: {
time.timeZone = config.universe.locale.timeZone;
i18n.defaultLocale = config.universe.locale.lang;
}

View file

@ -1,6 +1,6 @@
{ {config, ...}: {
networking = { networking = {
hostName = "earth"; hostName = config.universe.system.hostname;
networkmanager.enable = true; networkmanager.enable = true;
dhcpcd.enable = true; dhcpcd.enable = true;
}; };

18
host/system/nixpkgs.nix Normal file
View file

@ -0,0 +1,18 @@
{
config,
system,
...
}: {
system.stateVersion = "24.11";
nixpkgs = {
config = {
allowUnfree = config.universe.nixpkgs.allowUnfree;
allowBroken = true;
allowAliases = true;
allowInsecure = true;
allowUnfreePredicate = _: config.universe.nixpkgs.allowUnfree;
};
hostPlatform = system;
overlays = config.universe.nixpkgs.overlays;
};
}

78
host/system/users.nix Normal file
View file

@ -0,0 +1,78 @@
{
lib,
config,
pkgs,
...
}: let
cfg = config.universe;
in {
users = {
defaultUserShell = pkgs.fish;
users.${cfg.system.username} = {
isNormalUser = true;
extraGroups =
[
"wheel"
"input"
"networkmanager"
"video"
"audio"
]
++ (
if cfg.services.podman.enable
then ["podman"]
else []
)
++ (
if cfg.services.libvirtd.enable
then ["kvm"]
else []
)
++ (
if cfg.programs.android-tools.enable
then ["adbusers"]
else []
);
uid = 1000;
subGidRanges =
[]
++ (
if cfg.services.podman.enable
then [
{
count = 65536;
startGid = 100000;
}
]
else []
);
subUidRanges =
[]
++ (
if cfg.services.podman.enable
then [
{
count = 65536;
startUid = 100000;
}
]
else []
);
useDefaultShell = true;
openssh.authorizedKeys = {
keys = cfg.services.openssh.authorizedKeys;
};
shell = pkgs.fish;
};
groups =
{}
// lib.genAttrs (
[]
++ (
if cfg.programs.android-tools.enable
then ["adbusers"]
else []
)
) (name: {});
};
}

View file

@ -1,3 +0,0 @@
{...}: {
programs.amnezia-vpn.enable = true;
}

View file

@ -1,11 +0,0 @@
{
inputs,
system,
...
}: {
programs.hyprland = {
enable = true;
package = inputs.hyprland.packages.${system}.hyprland;
portalPackage = inputs.hyprland.packages.${system}.xdg-desktop-portal-hyprland;
};
}

View file

@ -1,7 +0,0 @@
{
inputs,
system,
...
}: {
programs.command-not-found.dbPath = inputs.programsdb.packages.${system}.programs-sqlite;
}

View file

@ -1,9 +0,0 @@
{...}: {
services.openssh = {
enable = true;
ports = [22 48001];
settings = {
PasswordAuthentication = false;
};
};
}

View file

@ -1,5 +0,0 @@
{pkgs, ...}: {
services.udev.packages = [
pkgs.android-udev-rules
];
}

View file

@ -1,4 +0,0 @@
{...}: {
time.timeZone = "Asia/Yekaterinburg";
i18n.defaultLocale = "en_US.UTF-8";
}

View file

@ -1,13 +0,0 @@
{system, ...}: {
system.stateVersion = "24.11";
nixpkgs = {
config = {
allowUnfree = true;
allowBroken = true;
allowAliases = true;
allowInsecure = true;
allowUnfreePredicate = _: true;
};
hostPlatform = system;
};
}

View file

@ -1,5 +0,0 @@
{...}: {
services.udev.extraRules = ''
KERNEL=="i2c-[0-9]*", GROUP="i2c", MODE="0660"
'';
}

View file

@ -1,44 +0,0 @@
{pkgs, ...}: {
users = {
defaultUserShell = pkgs.fish;
users."tx0" = {
isNormalUser = true;
extraGroups = [
"wheel"
"input"
"networkmanager"
"video"
"audio"
"podman"
"adbusers"
"kvm"
"i2c"
];
uid = 1000;
subGidRanges = [
{
count = 65536;
startGid = 100000;
}
];
subUidRanges = [
{
count = 65536;
startUid = 100000;
}
];
useDefaultShell = true;
openssh.authorizedKeys = {
keys = [
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCz8WZ+c24RYjBMVNZGMR+IjSQb7WtrMi2ZcfAf6BwNLaKJTlWABN20FSscbGy8oCdfheAKvdTrx+hMRNCmEdTmNZlDXZ0kDBFh1h3I2geC3XNWjXuYSSmZpfW71Tex5ZHpruD9lstL9rBVY7c1ZKJfmtgM5m+x44FZwjxdFffQbj9LtLmy6zWQ7iX7/zzcdPJvJxoQbBwmAeVqZErpR/IoSG2uXTS4tIqGStfg6kBoV/AZBwYCxE0f3jFzajTMm+n6kjnKOiztfaw+NVB4+QLlSvB5i3iJ7afjhv/KfH4/t0gmVCfqo+O9pPOUqLokQvHvAu33M6PP5Roc4mK+pGEYXabUdv757uo8RdDg6x3bu5kgJS+V06ZycnDtHYNda+8/qEh+nryu0TqqJtqALwO2k7VcTgDoMrU3UvXRSA3wIO+Gp8qbPVjJv1/jSKoVurmFe3Wwy0LVEA++zF4F571aOPzwY49q6AF+JuPCUWPy44K7oG6MfFPZSk7TtSelH18= timoxa@pc"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAka1w1Ld4KLiZfztI6Qqe5irM6g8G0ENGmqds+LWiGE"
];
};
shell = pkgs.fish;
};
groups = {
adbusers = {};
i2c = {};
};
};
}

View file

@ -1,16 +0,0 @@
{inputs, ...}: {
imports = [
inputs.sops-nix.nixosModules.sops
];
sops = {
# defaultSopsFile = ./secrets.yaml;
age.keyFile = "/home/tx0/.age-key.txt";
secrets."awg0.conf" = {
format = "binary";
sopsFile = ./awg0.conf;
path = "/run/secrets.d/awg0.conf";
restartUnits = ["awg0.service"];
};
};
}

View file

@ -1,3 +0,0 @@
{...}: {
virtualisation.libvirtd.enable = true;
}

View file

@ -1,6 +0,0 @@
{...}: {
virtualisation.podman = {
enable = true;
dockerCompat = true;
};
}

View file

@ -1,14 +0,0 @@
{...}: {
services.yggdrasil = {
enable = false;
settings = {
Peers = [
"tls://ygg1.tx0.su:65534"
"tls://ygg2.tx0.su:65534"
"tls://ygg3.tx0.su:65534"
];
IfName = "ygg";
};
};
}

View file

@ -1,2 +0,0 @@
{...}: {
}

View file

@ -1,20 +0,0 @@
{pkgs, ...}: {
systemd.services.awg0 = {
enable = true;
description = "AmneziaWG Interface awg0";
after = ["network.target"];
wantedBy = ["multi-user.target"];
unitConfig = {
ConditionPathExists = "/run/secrets.d/awg0.conf";
};
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStart = "${pkgs.amneziawg-tools}/bin/awg-quick up /run/secrets.d/awg0.conf";
ExecStop = "${pkgs.amneziawg-tools}/bin/awg-quick down /run/secrets.d/awg0.conf";
Restart = "on-failure";
};
};
}

46
machines/earth/earth.nix Normal file
View file

@ -0,0 +1,46 @@
{self, ...}: {
universe = {
programs = {
android-tools.enable = true;
};
system = {
tmpUseTmpfs = true;
emulatedSystems = ["aarch64-linux"];
arch = "x86_64-linux";
hostname = "earth";
username = "tx0";
};
nixpkgs = {
allowUnfree = true;
overlays = [(import "${self}/overlays/spotx.nix")];
};
locale = {
lang = "en_US.UTF-8";
timeZone = "Asia/Yekateringburg";
};
services = {
command-not-found.enable = true;
libvirtd.enable = false;
podman.enable = true;
openssh = {
enable = true;
ports = [22 48001];
authorizedKeys = [
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCz8WZ+c24RYjBMVNZGMR+IjSQb7WtrMi2ZcfAf6BwNLaKJTlWABN20FSscbGy8oCdfheAKvdTrx+hMRNCmEdTmNZlDXZ0kDBFh1h3I2geC3XNWjXuYSSmZpfW71Tex5ZHpruD9lstL9rBVY7c1ZKJfmtgM5m+x44FZwjxdFffQbj9LtLmy6zWQ7iX7/zzcdPJvJxoQbBwmAeVqZErpR/IoSG2uXTS4tIqGStfg6kBoV/AZBwYCxE0f3jFzajTMm+n6kjnKOiztfaw+NVB4+QLlSvB5i3iJ7afjhv/KfH4/t0gmVCfqo+O9pPOUqLokQvHvAu33M6PP5Roc4mK+pGEYXabUdv757uo8RdDg6x3bu5kgJS+V06ZycnDtHYNda+8/qEh+nryu0TqqJtqALwO2k7VcTgDoMrU3UvXRSA3wIO+Gp8qbPVjJv1/jSKoVurmFe3Wwy0LVEA++zF4F571aOPzwY49q6AF+JuPCUWPy44K7oG6MfFPZSk7TtSelH18= timoxa@pc"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAka1w1Ld4KLiZfztI6Qqe5irM6g8G0ENGmqds+LWiGE"
];
};
amneziawg = {
enable = true;
secret-config = ./awg0-earth.conf;
IfName = "awg0";
};
};
};
}

143
modules/universe.nix Normal file
View file

@ -0,0 +1,143 @@
{
lib,
boot,
...
}:
with lib; let
nixpkgsOverlayType = lib.mkOptionType {
name = "nixpkgs-overlay";
description = "nixpkgs overlay";
check = lib.isFunction;
merge = lib.mergeOneOption;
};
in {
options.universe = {
programs = {
amnezia-vpn.enable = mkEnableOption "Enable AmneziaVPN app";
android-tools.enable = mkEnableOption "Enable android tools (adb, fastboot, ...)";
};
system = {
tmpUseTmpfs = mkEnableOption "Use tmpfs for /tmp";
emulatedSystems = mkOption {
description = "Systems to emulate";
type = with types; listOf enum builtins.attrNames boot.binfmt.magics;
default = [];
};
arch = mkOption {
description = "System architecture";
type = with types; uniq str;
};
hostname = mkOption {
description = "System hostname";
type = with types; uniq str;
};
username = mkOption {
description = "Username";
type = with types; uniq str;
};
};
nixpkgs = {
allowUnfree = mkEnableOption "Enable non-free software";
overlays = mkOption {
description = "List of nixpkgs overlays";
type = with types; listOf nixpkgsOverlayType;
default = [];
};
};
locale = {
timeZone = mkOption {
description = "System time zone";
type = with types; uniq str;
default = "Asia/Yekaterinburg";
};
lang = mkOption {
description = "System locale";
type = with types; uniq str;
default = "en_US.UTF-8";
};
};
services = {
command-not-found.enable = mkEnableOption "Enable command-not-found";
libvirtd.enable = mkEnableOption "Enable libvirtd";
podman.enable = mkEnableOption "Enable libvirtd";
openssh = {
enable = mkEnableOption "Enable openssh server";
ports = mkOption {
description = "Listen ports";
type = with types; uniq (listOf port);
default = [22];
};
authorizedKeys = mkOption {
description = "Authorized public ssh keys";
type = with types; uniq (listOf str);
default = [];
};
};
amneziawg = {
enable = mkEnableOption "Enable amneziawg vpn service";
secret-config = mkOption {
description = "Configuration SOPS secret";
type = with types; nullOr path;
default = null;
};
IfName = mkOption {
description = "Interface name";
type = with types; uniq str;
};
};
};
de = {
hyprland = {
enable = mkEnableOption "Enable Hyprland";
};
waybar = {
enable = mkEnableOption "Enable waybar";
settings = {
radiuses = {
outer = mkOption {
type = types.int;
default = 100;
};
inner = mkOption {
type = types.int;
default = 40;
};
bar = mkOption {
type = types.int;
default = 25;
};
};
gapps = {
outer = mkOption {
type = types.int;
default = 6;
};
inner = mkOption {
type = types.int;
default = 8;
};
chips = mkOption {
type = types.int;
default = 4;
};
};
sizes = {
icons = mkOption {
type = types.int;
default = 20;
};
text = mkOption {
type = types.int;
default = 15;
};
};
};
};
};
};
}