feat: setup base

This commit is contained in:
tux
2026-05-06 00:55:41 +05:30
parent a62346367f
commit 33408ed45e
35 changed files with 1730 additions and 0 deletions

37
modules/nixos/core/hm.nix Normal file
View File

@@ -0,0 +1,37 @@
{ inputs, config, ... }:
{
flake.modules.nixos.core =
{
hostName,
userName,
userEmail,
...
}:
{
imports = [
inputs.home-manager.nixosModules.home-manager
];
home-manager = {
backupFileExtension = "bak";
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = {
inherit
inputs
hostName
userName
userEmail
;
};
users.${userName} = {
imports = [
config.flake.modules.homeManager.core
config.flake.modules.homeManager.shell
config.flake.modules.homeManager.${hostName}
];
};
};
};
}

20
modules/nixos/core/nh.nix Normal file
View File

@@ -0,0 +1,20 @@
{
flake.modules.nixos.core =
{
config,
userName,
...
}:
{
programs.nh = {
enable = true;
clean = {
enable = !config.nix.gc.automatic;
dates = "weekly";
};
flake = "/home/${userName}/Projects/nixos-config";
};
};
}

View File

@@ -0,0 +1,83 @@
{
flake.modules.nixos.core =
{ userName, ... }:
{
nix = {
channel.enable = false;
gc = {
automatic = true;
options = "--delete-older-than 7d";
dates = "weekly";
persistent = true;
};
optimise.automatic = true;
settings = {
experimental-features = [
"nix-command"
"flakes"
];
max-jobs = "auto";
# Make legacy nix commands use the XDG base directories instead of creating directories in $HOME.
use-xdg-base-directories = true;
# The maximum number of parallel TCP connections used to fetch files from binary caches and by other downloads.
# It defaults to 25. 0 means no limit.
http-connections = 128;
# This option defines the maximum number of substitution jobs that Nix will try to run in
# parallel. The default is 16. The minimum value one can choose is 1 and lower values will be
# interpreted as 1.
max-substitution-jobs = 128;
# The number of lines of the tail of the log to show if a build fails.
log-lines = 25;
# When free disk space in /nix/store drops below min-free during a build, Nix performs a
# garbage-collection until max-free bytes are available or there is no more garbage.
# A value of 0 (the default) disables this feature.
min-free = 128000000; # 128 MB
max-free = 1000000000; # 1 GB
# Prevent garbage collection from altering nix-shells managed by nix-direnv
# https://github.com/nix-community/nix-direnv#installation
keep-outputs = true;
keep-derivations = true;
# If set to true, Nix will keep building derivations even if some fail. The default is false.
keep-going = true;
# Automatically detect files in the store that have identical contents, and replaces
# them with hard links to a single copy. This saves disk space.
auto-optimise-store = true;
# Whether to warn about dirty Git/Mercurial trees.
warn-dirty = false;
# The timeout (in seconds) for establishing connections in the binary cache substituter.
# It corresponds to curls connect-timeout option. A value of 0 means no limit.
connect-timeout = 5;
# Allow the use of cachix
trusted-users = [
"root"
"${userName}"
];
allowed-users = [
"root"
"${userName}"
];
builders-use-substitutes = true;
# If set to true, Nix will fall back to building from source if a binary substitute
# fails. This is equivalent to the fallback flag. The default is false.
fallback = true;
};
};
};
}

View File

@@ -0,0 +1,12 @@
{ inputs, ... }:
{
flake.modules.nixos.core = {
nixpkgs = {
config = {
allowUnfree = true;
joypixels.acceptLicense = true;
};
overlays = builtins.attrValues inputs.self.overlays;
};
};
}

View File

@@ -0,0 +1,9 @@
{
flake.modules.nixos.core =
{ pkgs, ... }:
{
security = {
sudo.wheelNeedsPassword = false;
};
};
}

View File

@@ -0,0 +1,31 @@
{
flake.modules.nixos.core = {
nix.settings = {
substituters = [
"https://cache.nixos.org?priority=10"
"https://anyrun.cachix.org"
"https://fufexan.cachix.org"
"https://helix.cachix.org"
"https://hyprland.cachix.org"
"https://nix-community.cachix.org"
"https://nix-gaming.cachix.org"
"https://yazi.cachix.org"
"https://nix-on-droid.cachix.org"
"https://lan-mouse.cachix.org"
];
trusted-substituters = [ "https://nix-on-droid.cachix.org" ];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"anyrun.cachix.org-1:pqBobmOjI7nKlsUMV25u9QHa9btJK65/C8vnO3p346s="
"fufexan.cachix.org-1:LwCDjCJNJQf5XD2BV+yamQIMZfcKWR9ISIFy5curUsY="
"helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs="
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4="
"yazi.cachix.org-1:Dcdz63NZKfvUCbDGngQDAZq6kOroIrFoyO064uvLh8k="
"nix-on-droid.cachix.org-1:56snoMJTXmDRC1Ei24CmKoUqvHJ9XCp+nidK7qkMQrU="
"lan-mouse.cachix.org-1:KlE2AEZUgkzNKM7BIzMQo8w9yJYqUpor1CAUNRY6OyM="
];
};
};
}

View File

@@ -0,0 +1,29 @@
{
flake.modules.nixos.core =
{
pkgs,
userName,
userEmail,
...
}:
{
programs.zsh.enable = true;
users = {
mutableUsers = false;
defaultUserShell = pkgs.zsh;
users.${userName} = {
initialPassword = userName;
isNormalUser = true;
extraGroups = [
"networkmanager"
"wheel"
"storage"
];
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIL+OzPUe2ECPC929DqpkM39tl/vdNAXfsRnmrGfR+X3D ${userEmail}"
];
};
};
};
}