Compare commits

...

7 commits

21 changed files with 159 additions and 184 deletions

View file

@ -100,7 +100,7 @@
outputs = { self, nixpkgs, nix-on-droid, home-manager, stylix, ... } @inputs: {
# Constant values.
nixosModules.const = {
const = {
droidStateVersion = "22.11";
stateVersion = "23.11";
timeZone = "Europe/Moscow";
@ -108,35 +108,17 @@
};
# Common modules used across all hosts.
nixosModules.common.imports = [
./module/common/AutoUpdateSigned.nix
./module/common/Bash.nix
./module/common/Bootloader.nix
./module/common/Crypto.nix
./module/common/Distrobox.nix
./module/common/Dotfiles.nix
./module/common/Filesystem.nix
./module/common/Firefox.nix
./module/common/Firewall.nix
./module/common/Font.nix
./module/common/Git.nix
./module/common/KbdInterception.nix
./module/common/Kernel.nix
./module/common/Ld.nix
./module/common/Locale.nix
./module/common/Network.nix
./module/common/Nix.nix
./module/common/Nvim.nix
./module/common/Package.nix
./module/common/Ssh.nix
./module/common/Sshd.nix
./module/common/Stylix.nix
./module/common/Swap.nix
./module/common/Tmux.nix
./module/common/Users.nix
./module/common/YtDlp.nix
nixosModules.common = let
ls = path: map (f: "${path}/${f}") (
builtins.filter (i: builtins.readFileType "${path}/${i}" == "regular") (
builtins.attrNames (builtins.readDir path)
)
);
in {
imports = (ls ./module/common) ++ [
./user/Root.nix
];
};
# Function to create a host.
mkHost = { system, hostname, modules } @args: nixpkgs.lib.nixosSystem {
@ -145,7 +127,7 @@
modules = [
./host/${hostname}/Configuration.nix
{ networking.hostName = hostname; }
{ system.stateVersion = self.nixosModules.const.stateVersion; }
{ system.stateVersion = self.const.stateVersion; }
inputs.self.nixosModules.common
home-manager.nixosModules.home-manager
stylix.nixosModules.stylix
@ -155,7 +137,7 @@
pkgs = nixpkgs.legacyPackages.${system}.pkgs;
config = self.nixosConfigurations.${hostname}.config;
in {
const = self.nixosModules.const;
const = self.const;
flake = self;
inputs = inputs;
key = import ./part/Key.nix {};
@ -277,14 +259,14 @@
# Android.
nixOnDroidConfigurations.default = nix-on-droid.lib.nixOnDroidConfiguration {
modules = [
{ system.stateVersion = inputs.self.nixosModules.const.droidStateVersion; }
{ system.stateVersion = inputs.self.const.droidStateVersion; }
./module/NixOnDroid.nix
];
extraSpecialArgs = let
pkgs = nixpkgs.legacyPackages."aarch64-linux".pkgs;
in {
const = self.nixosModules.const;
const = self.const;
flake = self;
inputs = inputs;
key = import ./part/Key.nix {};

View file

@ -1,10 +1,10 @@
{ pkgs, inputs, const, style, util, key, setting, ... } @args: let
{ pkgs, inputs, const, style, util, key, setting, secret, ... } @args: let
homePath = "/data/data/com.termux.nix/files/home";
tmux = import ./common/tmux/Init.nix args;
tmux = import ./common/tmux args;
tmuxScript = pkgs.writeShellScriptBin "tmux_script" tmux.script;
bash = import ./common/bash/Init.nix args;
nvim = import ./common/nvim/Init.nix args;
ssh = import ./common/ssh/Init.nix args;
bash = import ./common/bash args;
nvim = import ./common/nvim args;
ssh = import ./common/ssh args;
font = pkgs.runCommandNoCC "font" {} ''
cp ${pkgs.nerdfonts.override { fonts = [ "Terminus" ]; }}/share/fonts/truetype/NerdFonts/TerminessNerdFontMono-Regular.ttf $out
'';
@ -13,7 +13,74 @@
foreground=#${style.color.fg.light}
'';
in {
# NOTE: Split into modules?
time.timeZone = const.timeZone;
nix.extraOptions = ''
experimental-features = nix-command flakes
'';
home-manager.config = {
home = {
stateVersion = const.droidStateVersion;
file = {
".dotfiles".source = inputs.self;
".ssh/config".text = ssh.config;
".termux/_font.ttf".source = font;
".termux/_colors.properties".text = colors;
};
sessionVariables = {
EDITOR = "nvim";
MANPAGER = "nvim +Man!";
NIXPKGS_ALLOW_UNFREE = "1";
NIX_CURRENT_SYSTEM = "${pkgs.stdenv.system}";
TERM = "xterm-256color";
};
};
programs = {
bash = {
enable = true;
bashrcExtra = bash.config + ''
[[ -f ~/.termux/font.ttf ]] || {
cp ~/.termux/_font.ttf ~/.termux/font.ttf
cp ~/.termux/_colors.properties ~/.termux/colors.properties
_warn "Termux config installed, please restart."
};
'';
};
tmux = {
enable = true;
extraConfig = tmux.config;
};
git = {
enable = true;
extraConfig = {
credential.helper = "store";
init.defaultBranch = "main";
pull.rebase = true;
push.autoSetupRemote = true;
rebase.autoStash = true;
user.signingkey = builtins.readFile secret.crypto.sign.key;
gpg.ssh.allowedSignersFile = toString(secret.crypto.sign.allowed);
gpg.format = secret.crypto.sign.format;
};
};
neovim = {
enable = true;
viAlias = true;
vimAlias = true;
extraConfig = nvim.config;
};
gpg = {
enable = true;
publicKeys = secret.crypto.publicKeys;
};
};
};
environment.packages = with pkgs; [
android-tools
binwalk
@ -31,13 +98,12 @@ in {
gnumake
gnused
gnutar
gzip
gzip xz
hostname
imagemagick
jq
lsof
man
neofetch
nmap
openssh
parallel
@ -49,60 +115,7 @@ in {
tree
utillinux
wget
xz
yt-dlp
zip unzip
];
time.timeZone = const.timeZone;
nix.extraOptions = ''
experimental-features = nix-command flakes
'';
home-manager.config = {
home.stateVersion = const.droidStateVersion;
home.file = {
".dotfiles".source = inputs.self;
".ssh/config".text = ssh.config;
".termux/_font.ttf".source = font;
".termux/_colors.properties".text = colors;
};
home.sessionVariables = {
EDITOR = "nvim";
MANPAGER = "nvim +Man!";
NIXPKGS_ALLOW_UNFREE = "1";
NIX_CURRENT_SYSTEM = "${pkgs.stdenv.system}";
TERM = "xterm-256color";
};
programs.bash = {
enable = true;
bashrcExtra = bash.config + ''
[[ -f ~/.termux/font.ttf ]] || {
cp ~/.termux/_font.ttf ~/.termux/font.ttf
cp ~/.termux/_colors.properties ~/.termux/colors.properties
_warn "Termux config installed, please restart."
};
'';
};
programs.tmux = {
enable = true;
extraConfig = tmux.config;
};
programs.git = {
enable = true;
extraConfig = {
credential.helper = "store";
init.defaultBranch = "main";
pull.rebase = true;
push.autoSetupRemote = true;
rebase.autoStash = true;
};
};
programs.neovim = {
enable = true;
viAlias = true;
vimAlias = true;
extraConfig = nvim.config;
};
};
}

View file

@ -1,9 +0,0 @@
{ ... }: {
packages.direnv = {
enable = true;
silent = true;
direnvrcExtra = ''
export NIX_SHELL="direnv"
'';
};
}

View file

@ -1,6 +1,9 @@
{ pkgs, lib, ... }: {
{ const, util, style, pkgs, lib, setting, key, secret, ... } @args: {
imports = [
./home/Dasha.nix
(import ./common (args // {
username = "dasha";
homeDir = "/home/dasha";
}))
];
users.users.dasha = {
createHome = true;

View file

@ -1,7 +1,11 @@
{ secret, ... }: {
{ const, util, style, pkgs, setting, key, secret, ... } @args: {
imports = [
./home/Root.nix
(import ./common (args // {
username = "root";
homeDir = "/root";
}))
];
users.users.root.hashedPassword = secret.hashedPassword;
security.sudo = {
enable = false;

View file

@ -1,6 +1,9 @@
{ pkgs, lib, secret, ... }: {
{ const, util, style, pkgs, lib, setting, key, secret, ... } @args: {
imports = [
./home/Voronind.nix
(import ./common (args // {
username = "voronind";
homeDir = "/home/voronind";
}))
];
users.users.voronind = {

53
user/common/default.nix Normal file
View file

@ -0,0 +1,53 @@
{ const, username, homeDir, util, style, pkgs, setting, key, secret, ... } @args: let
foot = import ./foot args;
mako = import ./mako args;
editorconfig = import ./editorconfig args;
btop = import ./top/btop args;
htop = import ./top/htop args;
in {
home-manager = {
backupFileExtension = "old";
users.${username} = {
home = {
username = username;
homeDirectory = homeDir;
stateVersion = const.stateVersion;
file = {
".config/btop/btop.conf".text = btop.config;
".config/htop/htoprc".text = htop.config;
".config/mako/config".text = mako.config;
".config/foot/foot.ini".text = foot.config;
".editorconfig".text = editorconfig.config;
".parallel/will-cite".text = "";
"media/template".source = ./template;
};
};
xdg.userDirs = {
enable = true;
createDirectories = true;
desktop = "${homeDir}/";
documents = "${homeDir}/document/";
download = "${homeDir}/download/";
music = "${homeDir}/media/music/";
pictures = "${homeDir}/media/picture/";
publicShare = "${homeDir}/media/share/";
templates = "${homeDir}/media/template/";
videos = "${homeDir}/media/video/";
extraConfig = {
XDG_TMP_DIR = "${homeDir}/tmp/";
};
};
programs = {
home-manager.enable = true;
gpg = {
enable = true;
publicKeys = secret.crypto.publicKeys;
};
};
};
};
}

View file

@ -1,8 +0,0 @@
{ const, util, style, pkgs, setting, key, secret, ... } @args: {
imports = [
(import ./common (args // {
username = "dasha";
homeDir = "/home/dasha";
}))
];
}

View file

@ -1,8 +0,0 @@
{ const, util, style, pkgs, setting, key, secret, ... } @args: {
imports = [
(import ./common (args // {
username = "root";
homeDir = "/root";
}))
];
}

View file

@ -1,8 +0,0 @@
{ const, util, style, pkgs, setting, key, secret, ... } @args: {
imports = [
(import ./common (args // {
username = "voronind";
homeDir = "/home/voronind";
}))
];
}

View file

@ -1,50 +0,0 @@
{ const, username, homeDir, util, style, pkgs, setting, key, secret, ... } @args: let
foot = import ./foot args;
mako = import ./mako args;
editorconfig = import ./editorconfig args;
btop = import ./top/btop args;
htop = import ./top/htop args;
in {
home-manager.backupFileExtension = "old";
home-manager.users.${username} = {
programs.home-manager.enable = true;
home.username = username;
home.homeDirectory = homeDir;
home.stateVersion = const.stateVersion;
home.file = {
".config/btop/btop.conf".text = btop.config;
".config/htop/htoprc".text = htop.config;
".config/mako/config".text = mako.config;
".config/foot/foot.ini".text = foot.config;
".editorconfig".text = editorconfig.config;
".parallel/will-cite".text = "";
"media/template".source = ./template;
};
# Directories.
xdg.userDirs = {
enable = true;
createDirectories = true;
desktop = "${homeDir}/";
documents = "${homeDir}/document/";
download = "${homeDir}/download/";
music = "${homeDir}/media/music/";
pictures = "${homeDir}/media/picture/";
publicShare = "${homeDir}/media/share/";
templates = "${homeDir}/media/template/";
videos = "${homeDir}/media/video/";
extraConfig = {
XDG_TMP_DIR = "${homeDir}/tmp/";
};
};
# GPG.
programs.gpg = {
enable = true;
publicKeys = secret.crypto.publicKeys;
};
};
}