Let's see what breaks! reorganize everything

This commit is contained in:
iFargle 2023-07-01 16:48:31 +09:00
parent 542edac678
commit 71dc7e809a
18 changed files with 162 additions and 363 deletions

View file

@ -1,3 +1,21 @@
# nix
Repo for nix configuration files
# Information
## Common
* Used to house all common configurations, including dotfiles
## Desktops
* Used to house DWM configurations, such as Gnome
## Hardware
* Contains hardware configurations
## Software
* Contains pieces of software, such as Promtail
## users
* Contains user configurations via home-manager
## Root
* `flake.nix` - The main configuration file for all systems

8
common/dotfiles/git.nix Normal file
View file

@ -0,0 +1,8 @@
programs.git = {
enable = true;
userName = "albert";
userEmail = "albert@sysctl.io";
extraConfig = {
credential.helper = "cache --timeout=25920000";
};
};

View file

@ -13,12 +13,10 @@
{ lib, config, pkgs, ... }: {
imports =
[
# Home-Manager Nix configuration file.
./home-manager.nix
# Gnome configuration file.
./gnome.nix
./desktops/gnome.nix
# Promtail logging
./promtail.nix
./software/promtail.nix
];
# Keep the system up-to-date automatically

101
flake.nix Normal file
View file

@ -0,0 +1,101 @@
{
description = "NixOS System Config";
inputs = {
# NixOS packages
nixpkgs.url = "nixpkgs/nixos-23.05";
# Manage dotfiles in a home directory
home-manager.url = "github:nix-community/home-manager/release-23.05";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
# Secureboot Configuration
lanzaboote.url = "github:nix-community/lanzaboote";
lanzaboote.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { nixpkgs, home-manager, lanzaboote, ... }:
let
system = "x86_64-linux";
hostname = "nixos-p1";
pkgs = import nixpkgs {
# Tells Flake what OS version we are using
inherit system;
config = { allowUnfree = true; };
};
lib = nixpkgs.lib;
in {
# Set up users with home-manager
homeManagerConfigurations = {
# Configuration for user "Albert"
albert = home-manager.lib.homeManagerConfiguration {
inherit system pkgs;
username = "albert";
homeDirectory = "/home/albert";
configuration = {
imports = [
./users/albert/home.nix;
];
};
};
# Configuration for user "root"
root = home-manager.lib.homeManagerConfiguration {
inherit system pkgs;
username = "root";
homeDirectory = "/root";
configuration = {
imports = [
./users/root/home.nix;
];
};
};
};
# NixOS Configuration files:
nixosConfigurations = {
# Declare the configuration for "nixos-laptop":
nixos-laptop = lib.nixosSystem {
inherit system hostname;
modules = [
# Hardware Configuration
./laptop/lenovo-p1.nix
# SecureBoot Configuration
lanzaboote.nixosModules.lanzaboote
# NixOS Configuration file
./configuration.nix
# Tell home-manager to use both global and user packages:
home-manager.nixosModules.home-manager {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
}
]; # modules
}; # lib.nixosSystem - nixos-laptop
# Declare the configuration for "nixos-p1", my laptop:
nixos-desktop = lib.nixosSystem {
inherit system hostname;
modules = [
# Hardware Configuration
./desktop/desktop.nix
# SecureBoot Configuration
lanzaboote.nixosModules.lanzaboote
# NixOS Configuration file
./configuration.nix
# Tell home-manager to use both global and user packages:
home-manager.nixosModules.home-manager {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
}
]; # modules
}; # lib.nixosSystem - nixos-laptop
}; # nixosConfiguration
};
}

View file

@ -1,46 +0,0 @@
{
description = "Laptop System Config";
inputs = {
# NixOS packages
nixpkgs.url = "nixpkgs/nixos-23.05";
# Manage dotfiles in a home directory
home-manager.url = "github:nix-community/home-manager/release-23.05";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
# Secureboot Configuration
lanzaboote.url = "github:nix-community/lanzaboote";
lanzaboote.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { nixpkgs, home-manager, lanzaboote, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
# Tells Flake what OS version we are using
inherit system;
config = { allowUnfree = true; };
};
lib = nixpkgs.lib;
in {
nixosConfigurations = {
# Declare the configuration for "nixos-p1", my laptop:
nixos-p1 = lib.nixosSystem {
inherit system;
modules = [
./hardware-configuration.nix
lanzaboote.nixosModules.lanzaboote
./configuration.nix
home-manager.nixosModules.home-manager {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
}
];
};
};
};
}

View file

@ -1,51 +0,0 @@
{ config, pkgs, lib, ... }:
{
# This configuration worked on 09-03-2021 nixos-unstable @ commit 102eb68ceec
# The image used https://hydra.nixos.org/build/134720986
boot = {
kernelPackages = pkgs.linuxPackages_rpi4;
tmpOnTmpfs = true;
initrd.availableKernelModules = [ "usbhid" "usb_storage" ];
# ttyAMA0 is the serial console broken out to the GPIO
kernelParams = [
"8250.nr_uarts=1"
"console=ttyAMA0,115200"
"console=tty1"
# A lot GUI programs need this, nearly all wayland applications
"cma=128M"
];
};
boot.loader.raspberryPi = {
enable = true;
version = 4;
};
boot.loader.grub.enable = false;
# Required for the Wireless firmware
hardware.enableRedistributableFirmware = true;
networking = {
hostName = "nixos-raspi-4"; # Define your hostname.
networkmanager = {
enable = true;
};
};
nix = {
autoOptimiseStore = true;
gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 30d";
};
# Free up to 1GiB whenever there is less than 100MiB left.
extraOptions = ''
min-free = ${toString (100 * 1024 * 1024)}
max-free = ${toString (1024 * 1024 * 1024)}
'';
};
system.stateVersion = "20.09";
}

View file

@ -1,171 +0,0 @@
{ 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";
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;
};
};
}

View file

@ -1,25 +0,0 @@
{ 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,49 +0,0 @@
{ config, pkgs, ... }: # A pinned version of Nixpkgs passed to the configuration by Nix
{
# Enable Nix flakes and the unified Nix CLI
nix.settings = {
experimental-features = "nix-command flakes";
};
# Networking configuration
networking.hostName = "fedora-p1";
# Enable OpenSSH
services.openssh.enable = true;
# Root filesystem
fileSystems."/" = {
device = "/dev/sda1";
fsType = "ext4";
};
# Create a user
users.users.albert = {
isNormalUser = false;
initialPassword = "Password";
};
# Configure Tailscale
# CLI tools, language runtimes, shells, and other desired packages
environment.systemPackages = with pkgs; [
curl
vim
git
htop
wget
tailscale
];
# Enable services:
services = {
tailscale = {
enable = true;
};
openssh = {
enable = true;
};
}
}

View file

@ -1,15 +0,0 @@
{
# 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";
}

View file

@ -1,6 +1,7 @@
# Generated via dconf2nix: https://github.com/gvolpe/dconf2nix
{ lib, ... }:
# dconf settings:
# https://github.com/gvolpe/dconf2nix
with lib.hm.gvariant;
{

15
users/albert/home.nix Normal file
View file

@ -0,0 +1,15 @@
{ config, pkgs, ... }: {
# Home-Manager Manual
# https://nix-community.github.io/home-manager/index.html
# Home-Manager Options Search
# https://mipmip.github.io/home-manager-option-search/
home-manager.users.albert = {
home.stateVersion = "23.05";
imports = [
./dconf.nix
../../common/dotfiles/git.nix
];
};
}

15
users/root/home.nix Normal file
View file

@ -0,0 +1,15 @@
{ config, pkgs, ... }: {
# Home-Manager Manual
# https://nix-community.github.io/home-manager/index.html
# Home-Manager Options Search
# https://mipmip.github.io/home-manager-option-search/
home-manager.users.root = {
home.stateVersion = "23.05";
imports = [
./dconf.nix
../../common/dotfiles/git.nix
];
};
}