rename systems -> hosts. Per host program specifications for user programs

This commit is contained in:
ringofstorms 2024-04-01 18:44:16 -05:00
parent ef0f74aae3
commit 2bea94afc4
23 changed files with 52 additions and 27 deletions

View file

@ -0,0 +1,10 @@
{ pkgs, ... }:
{
# I want this globally even for root so doing it outside of home manager
services.xserver.xkbOptions = "caps:escape";
console = {
earlySetup = true;
packages = with pkgs; [ terminus_font ];
useXkbConfig = true; # use xkb.options in tty. (caps -> escape)
};
}

View file

@ -0,0 +1,7 @@
{ pkgs, ... }:
{
fonts.packages = with pkgs; [
(nerdfonts.override { fonts = [ "JetBrainsMono" ]; })
];
}

View file

@ -0,0 +1,21 @@
{ pkgs, ... }:
{
services.xserver = {
enable = true;
displayManager.gdm = {
enable = true;
autoSuspend = false;
wayland = true;
};
desktopManager.gnome.enable = true;
};
services.gnome.core-utilities.enable = false;
environment.systemPackages = with pkgs; [
gnome.dconf-editor
gnomeExtensions.workspace-switch-wraparound
# wayland clipboard in terminal
wl-clipboard
];
environment.sessionVariables.NIXOS_OZONE_WL = "1";
}

View file

@ -0,0 +1,19 @@
{ pkgs, ... }:
{
services.xserver = {
enable = true;
displayManager.gdm = {
enable = true;
autoSuspend = false;
wayland = false;
};
desktopManager.gnome.enable = true;
};
services.gnome.core-utilities.enable = false;
environment.systemPackages = with pkgs; [
gnome.dconf-editor
gnomeExtensions.workspace-switch-wraparound
xclip
];
}

View file

@ -0,0 +1,22 @@
{ config, pkgs, settings, ylib, ... } @ inputs:
let
home-manager = builtins.fetchTarball {
url = "https://github.com/nix-community/home-manager/archive/release-23.11.tar.gz";
# to get hash run `nix-prefetch-url --unpack "https://github.com/nix-community/home-manager/archive/release-23.11.tar.gz"`
sha256 = "0g51f2hz13dk953i501fmc6935difhz60741nypaqwz127hy5ldk";
};
in
{
imports =
[
# home manager import
(import "${home-manager}/nixos")
];
# Home manager options
security.polkit.enable = true;
home-manager.useUserPackages = true;
home-manager.useGlobalPkgs = true;
home-manager.extraSpecialArgs = { inherit settings; inherit ylib; inherit (inputs) ragenix; inherit (config) age; };
}

View file

@ -0,0 +1,10 @@
{ ... }:
{
# Enable the OpenSSH daemon.
services.openssh.enable = true;
services.openssh.settings.PermitRootLogin = "yes";
# Open ports in the firewall.
networking.firewall.allowedTCPPorts = [
22 # sshd
];
}

View file

@ -0,0 +1,15 @@
{ ... }:
{
# Use the systemd-boot EFI boot loader.
boot.loader = {
systemd-boot = {
enable = true;
consoleMode = "keep";
};
timeout = 5;
efi = {
canTouchEfiVariables = true;
};
};
}

View file

@ -0,0 +1,14 @@
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [
# extras, more for my neovim setup TODO move these into a more isolated place for nvim setup? Should be its own flake probably
neovim
cargo
rustc
nodejs_21
python313
nodePackages.cspell
# ripgrep (now in common but will be needed in neovim flake)
];
}

View file

@ -0,0 +1,94 @@
{ config, lib, pkgs, settings, ylib, ... } @ inputs:
let
defaultLocal = "en_US.UTF-8";
in
{
imports =
[
# Secrets management
./ragenix.nix
# Include the results of the hardware scan.
(/${settings.hostsDir}/${settings.system.hostname}/hardware-configuration.nix)
# Include the specific machine's config.
(/${settings.hostsDir}/${settings.system.hostname}/configuration.nix)
];
# Enable flakes
nix.settings.experimental-features = [ "nix-command" "flakes" ];
# ==========
# Common
# ==========
networking.hostName = settings.system.hostname;
# TODO do I want this dynamic at all? Roaming?
time.timeZone = "America/Chicago";
# Select internationalization properties.
i18n.defaultLocale = defaultLocal;
i18n.extraLocaleSettings = {
LC_ADDRESS = defaultLocal;
LC_IDENTIFICATION = defaultLocal;
LC_MEASUREMENT = defaultLocal;
LC_MONETARY = defaultLocal;
LC_NAME = defaultLocal;
LC_NUMERIC = defaultLocal;
LC_PAPER = defaultLocal;
LC_TELEPHONE = defaultLocal;
LC_TIME = defaultLocal;
};
# Some basics
nixpkgs.config.allowUnfree = true;
environment.systemPackages = with pkgs; [
# Basics
# neovim in TODO nix file in common, to split out into its own flake eventually
vim
wget
curl
neofetch
bat
htop
nvtop
unzip
git
fzf
ripgrep
# TODO keep in common or move to specific machines, I want this for my pocket 3 video KDM module but I use ffmpeg on most machines anyways?
ffmpeg_5-full
];
environment.shellAliases = {
n = "nvim";
nn = "nvim --headless '+SessionDelete' +qa > /dev/null 2>&1 && nvim";
bat = "bat --theme Coldark-Dark";
cat = "bat --pager=never -p";
nix-boot-clean = "find '/boot/loader/entries' -type f ! -name 'windows.conf' | head -n -4 | xargs -I {} rm {}; nix-collect-garbage -d; nixos-rebuild boot; echo; df";
# general unix
date_compact = "date +'%Y%m%d'";
date_short = "date +'%Y-%m-%d'";
ls = "ls --color -Ga";
ll = "ls --color -Gal";
lss = "du --max-depth=0 -h * 2>/dev/null";
psg = "ps aux | head -n 1 && ps aux | grep -v 'grep' | grep";
cl = "clear";
# git
stash = "git stash";
pop = "git stash pop";
branch = "git checkout -b";
status = "git status";
diff = "git diff";
branches = "git branch -a";
gcam = "git commit -a -m";
stashes = "git stash list";
# ripgrep
rg = "rg --no-ignore";
rgf = "rg --files 2>/dev/null | rg";
};
environment.shellInit = builtins.readFile ./shellInit.sh;
system.stateVersion = "23.11";
}

29
hosts/_common/ragenix.nix Normal file
View file

@ -0,0 +1,29 @@
# TODO check out the by host way this person does: https://github.com/hlissner/dotfiles/blob/089f1a9da9018df9e5fc200c2d7bef70f4546026/modules/agenix.nix
{ settings, lib, ragenix, ... }:
let
# secretsFile = (settings.secretsDir + /secrets.nix);
in
{
imports = [ ragenix.nixosModules.age ];
environment.systemPackages = [ ragenix.packages.${settings.system.system}.default ];
age = {
secrets =
# builtins.mapAttrs
# (name: _value: lib.nameValuePair (lib.removeSuffix ".age" name) {
# file = (settings.secretsDir + "/${name}");
# owner = lib.mkDefault settings.user.username;
# })
# (import secretsFile);
{
nix2github = {
file = /${settings.secretsDir}/nix2github.age;
owner = settings.user.username;
};
nix2bitbucket = {
file = /${settings.secretsDir}/nix2bitbucket.age;
owner = settings.user.username;
};
};
};
}

110
hosts/_common/shellInit.sh Normal file
View file

@ -0,0 +1,110 @@
# basics
htop_psg () {
htop -p $(psg $1 | awk '{r=r s $2;s=","} END{print r}')
}
htop_pid () {
htop -p $(ps -ef | awk -v proc=$1 '$3 == proc { cnt++;if (cnt == 1) { printf "%s",$2 } else { printf ",%s",$2 } }')
}
kill_psg() {
PIDS=$(ps aux | grep -v "grep" | grep ${1} | awk '{print $2}')
echo Killing ${PIDS}
for pid in ${PIDS}; do
kill -9 ${pid} &> /dev/null
done
}
term_psg() {
PIDS=$(ps aux | grep -v "grep" | grep ${1} | awk '{print $2}')
echo Terminating ${PIDS}
for pid in ${PIDS}; do
kill -15 ${pid} &> /dev/null
done
}
skill_psg() {
PIDS=$(ps aux | grep -v "grep" | grep ${1} | awk '{print $2}')
echo Quitting ${PIDS}
for pid in ${PIDS}; do
sudo kill -9 ${pid} &> /dev/null
done;
}
mail_clear() {
: > /var/mail/$USER
}
# git
getdefault () {
git remote show origin | grep "HEAD branch" | sed 's/.*: //'
}
master () {
git stash
git checkout $(getdefault)
pull
}
mp () {
master
prunel
}
pullmaster () {
git pull origin $(getdefault)
}
push () {
B=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
git pull origin $B
git push origin $B --no-verify
}
pull () {
git fetch
B=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
git pull origin $B
}
forcepush () {
B=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
git push origin $B --force
}
remote_branches () {
git branch -a | grep 'remotes' | grep -v -E '.*(HEAD|${DEFAULT})' | cut -d'/' -f 3-
}
local_branches () {
git branch -a | grep -v 'remotes' | grep -v -E '.*(HEAD|${DEFAULT})' | grep -v '^*' | cut -d' ' -f 3-
}
prunel () {
git fetch
git remote prune origin
for local in $(local_branches); do
in=false
for remote in $(remote_branches); do
if [[ ${local} = ${remote} ]]; then
in=true
fi
done;
if [[ $in = 'false' ]]; then
git branch -D ${local}
else
echo 'Skipping branch '${local}
fi
done;
}
checkout () {
git fetch
git checkout $1
pull
}
from_master () {
git checkout $(getdefault) $@
}