split home and user up to allow for modular configuration

This commit is contained in:
janis 2025-11-18 16:54:18 +01:00
parent 74be2fe1d6
commit 71e36690a3
Signed by: janis
SSH key fingerprint: SHA256:bB1qbbqmDXZNT0KKD5c2Dfjg53JGhj7B3CFcLIzSqq8
13 changed files with 282 additions and 201 deletions

View file

@ -2,6 +2,7 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
nixos-wsl.url = "github:nix-community/NixOS-WSL/main";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
@ -19,7 +20,7 @@
duralumin.url = "git+https://git.nirgendwo.xyz/janis/duralumin.git";
};
outputs = inputs @ { self, disko, nixpkgs, nixpkgs-unstable, home-manager, duralumin, emacs-overlay, ... }:
outputs = inputs @ { self, disko, nixpkgs, nixos-wsl, nixpkgs-unstable, home-manager, duralumin, emacs-overlay, ... }:
let
system = "x86_64-linux";
overlay-unstable = final: prev: {
@ -30,12 +31,12 @@
};
in rec {
mkSystem = {host, ...}: nixpkgs.lib.nixosSystem {
mkSystem = {host, extra-modules ? [], ...}: nixpkgs.lib.nixosSystem {
inherit system;
modules = [
./configuration.nix
./options.nix
./programs
./options.nix
./pkgs
host
home-manager.nixosModules.home-manager
@ -48,7 +49,7 @@
inherit inputs;
};
}
];
] ++ extra-modules;
specialArgs = {
inherit inputs home-manager;
@ -74,9 +75,37 @@
};
laptop = mkSystem {
host = ./hosts/laptop;
extra-modules = [
./user
./system
];
};
desktop = mkSystem {
host = ./hosts/desktop;
extra-modules = [
./user
./system
];
};
wsl = mkSystem {
host = ./hosts/wsl.nix;
extra-modules = [
nixos-wsl.nixosModules.default
./user/wsl.nix
{
wsl.enable = true;
# wsl wants a subset of the system configuration, sans power, wireless, boot
imports = [
./system/core.nix
./system/networking.nix
./system/fonts.nix
./system/virtualisation.nix
];
}
];
};
};
};

60
home/common.nix Normal file
View file

@ -0,0 +1,60 @@
{pkgs, ...}:
let
user = import ../data/user.nix {};
in {
# Manage NixOS configurations
programs.nh = {
enable = true;
};
# Direnv for project-specific environment variables
programs.direnv = {
enable = true;
nix-direnv.enable = true;
enableZshIntegration = true;
};
# Font configuration
fonts.fontconfig.enable = true;
home = {
stateVersion = "25.05";
homeDirectory = "/home/${user.username}";
username = user.username;
shell.enableZshIntegration = true;
sessionVariables = {
SSH_AUTH_SOCK = "/run/user/1000/ssh-agent";
EDITOR = "nvim";
VISUAL = "nvim";
GTK_THEME = "Breeze-Dark";
NIXOS_OZONE_WL = "1";
};
packages = with pkgs; [
# Add your global packages here
duralumin
duralumin-keygen
ranger
neovim
bottom
git
wget
curl
tree
htop
ripgrep
killall
xdg-utils
file
gh
# for running wayland apps over ssh
waypipe
screenshot
];
};
}

View file

@ -1,9 +1,8 @@
{pkgs, ...}:
let
user = import ../data/user.nix {};
in {
{...}: {
imports = [
./alacritty.nix
./common.nix
./desktop-apps.nix
./development
./emacs.nix
./firefox.nix
@ -20,89 +19,4 @@ in {
./waybar.nix
./zsh.nix
];
programs.nh = {
enable = true;
# flake = "/etc/nixos/config#laptop"
};
programs.direnv = {
enable = true;
nix-direnv.enable = true;
enableZshIntegration = true;
};
xdg = {
systemDirs.data = ["${pkgs.nordvpn}/share"];
portal = {
enable = true;
extraPortals = with pkgs; [
xdg-desktop-portal
xdg-desktop-portal-wlr
xdg-desktop-portal-gtk
xdg-desktop-portal-xapp
];
};
};
fonts.fontconfig.enable = true;
home = {
stateVersion = "25.05";
homeDirectory = "/home/${user.username}";
username = user.username;
shell.enableZshIntegration = true;
sessionVariables = {
SSH_AUTH_SOCK = "/run/user/1000/ssh-agent";
EDITOR = "nvim";
VISUAL = "nvim";
GTK_THEME = "Breeze-Dark";
NIXOS_OZONE_WL = "1";
};
packages = with pkgs; [
# Add your global packages here
mpv
sxiv
feh
duralumin
duralumin-keygen
ranger
neovim
bottom
git
wget
curl
htop
tree
htop
pavucontrol
ripgrep
killall
x11_ssh_askpass
xdg-utils
vanilla-dmz
(discord.override {withVencord = true;})
spotify
pkgs.unstable.zed-editor-fhs
file
bitwarden-desktop
bitwarden-cli
prismlauncher
virt-manager
gh
# for running wayland apps over ssh
waypipe
foliate
# file manager
nemo-with-extensions
screenshot
];
};
}

27
home/desktop-apps.nix Normal file
View file

@ -0,0 +1,27 @@
{pkgs, ...}: {
packages = with pkgs; [
# Video/Image Viewers
mpv
feh
sxiv
vanilla-dmz
whitesur-cursors
x11_ssh_askpass
pavucontrol
(discord.override {withVencord = true;})
spotify
pkgs.unstable.zed-editor-fhs
bitwarden-desktop
bitwarden-cli
# Minecraft Launcher
prismlauncher
virt-manager
foliate
# GUI File Manager
nemo-with-extensions
];
}

View file

@ -15,11 +15,12 @@ in {
wmctrl
alsa-utils
wireplumber
alacritty
waybar
sway
whitesur-cursors
rofi-wayland
alacritty
vanilla-dmz
whitesur-cursors
];
wayland = {

11
home/wsl.nix Normal file
View file

@ -0,0 +1,11 @@
{...}: {
imports = [
./common.nix
./development
./emacs.nix
./git-ssh.nix
./syncthing.nix
./theme.nix
./zsh.nix
];
}

14
home/xdg.nix Normal file
View file

@ -0,0 +1,14 @@
{pkgs, ...}: {
xdg = {
systemDirs.data = ["${pkgs.nordvpn}/share"];
portal = {
enable = true;
extraPortals = with pkgs; [
xdg-desktop-portal
xdg-desktop-portal-wlr
xdg-desktop-portal-gtk
xdg-desktop-portal-xapp
];
};
};
}

70
system/core.nix Normal file
View file

@ -0,0 +1,70 @@
{pkgs, ...}: {
environment.systemPackages = with pkgs; [
# Basic utilities
zsh
wget
curl
git
vim
htop
linux-firmware
linuxHeaders
];
nix.settings.experimental-features = [
"nix-command"
"flakes"
];
system = {
stateVersion = "25.05";
activationScripts = {
rfkill-unblock = {
text = ''
rfkill unblock all
'';
deps = [];
};
};
};
time.hardwareClockInLocalTime = true;
security = {
polkit.enable = true;
rtkit.enable = true;
sudo.wheelNeedsPassword = false; # Allow sudo without password
};
time.timeZone = "Europe/Amsterdam";
i18n.defaultLocale = "en_GB.UTF-8";
console = {
font = "Lat2-Terminus16";
keyMap = "uk";
};
services = {
dbus.implementation = "broker";
pipewire = {
enable = true;
pulse.enable = true;
alsa.enable = true;
alsa.support32Bit = true;
};
openssh = {
enable = true;
settings = {
PasswordAuthentication = true; # Enable password authentication.
./user
PermitRootLogin = "yes"; # Allow root login (not recommended for production).
};
};
libinput.enable = true;
};
}

View file

@ -1,6 +1,7 @@
{pkgs, ...}: {
{...}: {
imports = [
./boot.nix
./core.nix
./fonts.nix
./hardware.nix
./networking.nix
@ -9,72 +10,4 @@
./virtualisation.nix
./wireless.nix
];
environment.systemPackages = with pkgs; [
# Basic utilities
zsh
wget
curl
git
vim
htop
linux-firmware
linuxHeaders
];
nix.settings.experimental-features = [
"nix-command"
"flakes"
];
system = {
stateVersion = "25.05";
activationScripts = {
rfkill-unblock = {
text = ''
rfkill unblock all
'';
deps = [];
};
};
};
time.hardwareClockInLocalTime = true;
security = {
polkit.enable = true;
rtkit.enable = true;
sudo.wheelNeedsPassword = false; # Allow sudo without password
};
time.timeZone = "Europe/Amsterdam";
i18n.defaultLocale = "en_GB.UTF-8";
console = {
font = "Lat2-Terminus16";
keyMap = "uk";
};
services = {
dbus.implementation = "broker";
pipewire = {
enable = true;
pulse.enable = true;
alsa.enable = true;
alsa.support32Bit = true;
};
openssh = {
enable = true;
settings = {
PasswordAuthentication = true; # Enable password authentication.
PermitRootLogin = "yes"; # Allow root login (not recommended for production).
};
};
libinput.enable = true;
};
}

27
user/common.nix Normal file
View file

@ -0,0 +1,27 @@
{config, pkgs, ...}:
let
user = import ../data/user.nix {};
in {
imports = [
../options.nix
];
users.users.${user.username} = {
shell = pkgs.zsh;
group = "users";
home = "/home/${user.username}";
createHome = true;
isNormalUser = true;
extraGroups = [ "wheel" "input" "nordvpn" "networkmanager" "libvirtd" ];
};
programs.zsh.enable = true;
programs.dconf.enable = true;
programs.ssh = {
startAgent = true;
};
home-manager.extraSpecialArgs = {
super-config = config;
};
}

View file

@ -1,45 +1,16 @@
{config, pkgs, ...}:
{...}:
let
user = import ../data/user.nix {};
in {
imports = [
../options.nix
../options.nix
./common.nix
./greetd.nix
];
users.users.${user.username} = {
shell = pkgs.zsh;
group = "users";
home = "/home/${user.username}";
createHome = true;
isNormalUser = true;
extraGroups = [ "wheel" "input" "nordvpn" "networkmanager" "libvirtd" ];
};
programs.zsh.enable = true;
programs.dconf.enable = true;
programs.ssh = {
startAgent = true;
};
services = {
udisks2.enable = true;
# xserver.enable = true;
# xserver.displayManager.sddm.enable = true;
greetd = {
enable = true;
settings = {
default_session = {
command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd 'dbus-run-session sway'";
user = "greeter";
};
};
};
};
services.udisks2.enable = true;
home-manager.users.${user.username} = { ... }: {
imports = [ ../home ];
};
home-manager.extraSpecialArgs = {
super-config = config;
};
}

11
user/greetd.nix Normal file
View file

@ -0,0 +1,11 @@
{pkgs, ...}: {
services.greetd = {
enable = true;
settings = {
default_session = {
command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd 'dbus-run-session sway'";
user = "greeter";
};
};
};
}

13
user/wsl.nix Normal file
View file

@ -0,0 +1,13 @@
{...}:
let
user = import ../data/user.nix {};
in {
imports = [
../options.nix
./common.nix
];
home-manager.users.${user.username} = { ... }: {
imports = [ ../home/wsl.nix ];
};
}