Lots of NIX Teesing

This commit is contained in:
iFargle 2023-06-29 15:32:19 +09:00
parent a1c3fc3649
commit 8157a63f9e
4 changed files with 232 additions and 7 deletions

173
server/configuration.nix Normal file
View file

@ -0,0 +1,173 @@
{ config, pkgs, ...}: {
# Desktop/Laptop configuration.nix
# Import other files to this config:
imports = [
./home-manager.nix
./variables.nix
];
# Basic configs
time.timeZone = ${timezone}
# Boot settings
boot = {
blacklistedKernelModules = [ "nouveau" ];
cleanTmpDir = true;
};
# Keep the system up-to-date automatically
system = {
stateVersion = ${nixos-version}
autoUpgrade = {
enable = true;
allowReboot = false;
channel = https://channels.nixos.org/nixos-${nixos-version}
};
};
# Networking:
networking = {
hostname = ${hostname};
enableIPv6 = false;
firewall = {
enable = true;
allowedTCPPorts = [ 22 ];
allowedUDPPorts = [ 41641 ];
};
networkmanager = {
enable = true;
};
};
# Create a user:
# https://nixos.org/manual/nixos/stable/index.html#sec-user-management
users.users.${username} = {
isNormalUser = false;
initialPassword = "Password";
description = "${user-full-name}";
extraGroups = [ "wheel", "networkmanager" ];
uid = 1000;
shell = "/bin/bash"
};
# Enable various services:
services = {
openssh = {
enable = true;
};
ntp = {
enable = true;
};
tailscale = {
enable = true;
useRoutingFeatures = "server";
};
# X Display Manager
# https://nixos.org/manual/nixos/stable/index.html#sec-x11
xserver = {
enable = true;
videoDrivers = nvidia;
autorun = true;
layout = "en";
displayManager = {
gdm = {
enable = true;
};
};
desktopManager = {
gnome = {
enable = true;
};
};
# https://nixos.org/manual/nixos/stable/index.html#sec-gnome-enable
# Adding icon themes: https://nixos.org/manual/nixos/stable/index.html#sec-gnome-icons-and-gtk-themes
gnome = {
core-utilities.enable = false;
games.enable = false;
};
};
pipewire = {
enable = true;
alsa.enable = true;
alsa.support32bit = true;
};
};
# NixPkgs configuration
nixpkgs = {
system = "${system-arch}"
config = {
allowUnfree = true;
};
};
# Install various packages
environment = {
systemPackages = with pkgs; [
vim
git
curl
htop
tailscale
iftop
jq
zip
tar
bash
];
# If a GUI is enabled, install GUI apps:
if config.services.xserver.enable then [
pkgs.firefox
pkgs.steam
pkgs.bitwarden
pkgs.lutris
pkgs.vscodium
pkgs.vlc
];
};
# Configure programs
programs = {
bash = {
enableCompletion = true;
enableLsColors = true;
shellAliases = {
d = "docker";
dc = "docker-compose";
de = "docker exec -it";
ddate = "date +%Y.%m.%d";
dday = "date +%A";
e = "emacsclient -nw"; # emacs in a terminal
f = "fossil";
g = "git";
ga = "git add -A";
gb = "git branch";
gc = "git commit";
gca = "git commit -a";
gco = "git checkout";
gd = "git diff";
gl = "git pull --prune";
gp = "git push origin HEAD";
gs = "git status -sb";
hs = "home-manager switch";
ll = "ls -lah";
rm = "rm -i";
tdate = "date +%Y.%m.%d..%H.%M";
ttime = "date +%H.%M";
}
};
firefox = {
# https://nixos.org/manual/nixos/stable/options.html#opt-programs.firefox.preferences
};
vim = {
defaultEditor = true;
};
xwayland = {
enable = true;
};
dconf = {
enable = true;
};
};
}

25
server/home-manager.nix Normal file
View file

@ -0,0 +1,25 @@
{ config, pkgs, ... }:
# https://mipmip.github.io/home-manager-option-search/
# https://nix-community.github.io/home-manager/index.html
let
if ${nixos-version} == "unstable":
home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/master.tar.gz";
in
{
imports = [
(import "${home-manager}/nixos")
./variables.nix
];
home-manager.users.${username} = {
/* The home.stateVersion option does not have a default and must be set */
home.stateVersion = "${nixos-version}";
/* Here goes the rest of your home-manager config, e.g. home.packages = [ pkgs.foo ]; */
programs.git = {
enable = true;
userName = "${username}";
userEmail = "${email_address}";
};}
};
}

View file

@ -1,4 +1,4 @@
{ pkgs, ... }: # A pinned version of Nixpkgs passed to the configuration by Nix { config, pkgs, ... }: # A pinned version of Nixpkgs passed to the configuration by Nix
{ {
# Enable Nix flakes and the unified Nix CLI # Enable Nix flakes and the unified Nix CLI
@ -24,14 +24,26 @@
initialPassword = "Password"; initialPassword = "Password";
}; };
# Configure Tailscale
# CLI tools, language runtimes, shells, and other desired packages # CLI tools, language runtimes, shells, and other desired packages
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
curl curl
jq vim
wget
git git
python htop
openssl wget
zsh tailscale
]; ];
}sssss
# Enable services:
services = {
tailscale = {
enable = true;
};
openssh = {
enable = true;
};
}
}

15
server/variables.nix Normal file
View file

@ -0,0 +1,15 @@
{
# User configs
username = "albert";
user-full-name = "Albert J. Copeland";
email_address = "albert@sysctl.io";
# Machine configs
hostname = "p1-fedora";
hardware-type = "desktop"; # Desktop, Laptop, Server
system-arch = "x86_64-linux";
# OS configs
nixos-version = "unstable";
timezone = "Asia/Tokyo";
}