Compare commits

..

No commits in common. "d34ce8f4b23ae7f63b316c845d040658b034bd22" and "2937154e38ab3f589273358c0beac4ff8849fc0e" have entirely different histories.

57 changed files with 414 additions and 379 deletions

View File

@ -1,37 +1,28 @@
# Installing on a new machine
1) Install [NixOS](https://nixos.org/) from an ISO via USB
2) Reboot machine
3) Edit `/etc/nixos/configuration.nix` and add `git` to packages
3) Edit `/etc/nixos/configuration` and add `git` to packages
4) Clone this repo
5) Create a new directory under `hosts/` for the new machine
6) Copy `/etc/nixos/hardware-configuration.nix` to `hosts/<host>/hardware.nix`
7) Register the host in `flake.nix` via `mkHost`:
```nix
nixosConfigurations.<host> = mkHost { host = "<host>"; };
```
5) Copy new `host/` configuration for the new machine
6) Copy `/etc/nixos/hardware-configuration` to `host/<host>/hardware.nix`
7) Edit `flake.nix` to point to the new `host`
8) `git add .`
9) Run `sudo nixos-rebuild switch --flake .#<host>`
9) Run `sudo nixos-rebuild switch --flake .#nixos`
# Building NixOS VM
`nix build .#nixosConfigurations.vm.config.system.build.vm`
or run `./build-vm.sh` (removes `./vm.qcow2` first)
`nix build .#nixosConfigurations.nixosvm.config.system.build.vm`
https://gist.github.com/FlakM/0535b8aa7efec56906c5ab5e32580adf
# Building NixOS ISO
`nix build .#nixosConfigurations.live.config.system.build.isoImage`
or run `./build-iso.sh`
# Using Standalone Home Manager
1) Install [Nix](https://nixos.org/) via:
```
`
sh <(curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install) --daemon
```
`
2) Create `~/.config/nix/nix.conf` file with the following contents to enable the use of flakes:
```
@ -40,16 +31,14 @@ experimental-features = nix-command flakes
3) Install `git`
4) Clone this repo
5) Edit `flake.nix` variables as needed
6) `home-manager switch --flake .#josh`
6) `home-manager switch --flake .`
# Misc
## Garbage collection
`nix-collect-garbage -d`
## Fonts
### Checking installed fonts
`fc-list`
### Debugging kitty fonts
`kitty --debug-font-fallback`

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash
#/usr/bin/env bash
echo "Building ISO ..."
nix build .#nixosConfigurations.live.config.system.build.isoImage

102
flake.nix
View File

@ -47,72 +47,98 @@
}@inputs:
let
system = "x86_64-linux";
username = "josh";
profile = "desktop";
homePath = ./. + "/users/${username}/home.nix";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [ nix-vscode-extensions.overlays.default ];
};
mkHost =
{
host,
extraModules ? [ ],
}:
nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = {
inherit
homePath
host
inputs
profile
username
;
};
inherit pkgs;
modules = [ ./hosts/${host} ] ++ extraModules;
};
in
{
nixosConfigurations = {
laptop = mkHost { host = "laptop"; };
laptop = let
host = "laptop";
profile = "desktop";
username = "josh";
in nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = {
inherit inputs;
inherit host;
inherit profile;
inherit username;
};
pkgs = pkgs;
modules = [
./hosts/${host}
];
};
vm = mkHost { host = "vm"; };
vm = let
host = "vm";
profile = "desktop";
username = "josh";
in nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = {
inherit inputs;
inherit host;
inherit profile;
inherit username;
};
pkgs = pkgs;
modules = [
./hosts/${host}
];
};
live = mkHost {
live = let
host = "installation-iso";
extraModules = [
profile = "desktop";
username = "josh";
in nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = {
inherit inputs;
inherit host;
inherit profile;
inherit username;
};
pkgs = pkgs;
modules = [
(nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix")
{ environment.systemPackages = [ install-system.packages.${system}.default ]; }
./hosts/installation-iso
];
};
};
homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration {
extraSpecialArgs = {
inherit inputs profile username;
};
inherit pkgs;
homeConfigurations.josh = let
profile = "desktop";
username = "josh";
gpgSigningKey = null;
in home-manager.lib.homeManagerConfiguration {
extraSpecialArgs = {
inherit inputs;
inherit profile;
inherit username;
};
pkgs = pkgs;
modules = [
{
modules.gpg.signingKey = null;
modules.gpg.signingKey = gpgSigningKey;
}
homePath
./homes/josh/home.nix
stylix.homeModules.stylix
];
};
devShell.${system} = pkgs.mkShell {
packages = with pkgs; [
devShell.${system} = nixpkgs.legacyPackages.${system}.pkgs.mkShell {
packages = with nixpkgs.legacyPackages.${system}.pkgs; [
nil
nixd
];
};
formatter.${system} = pkgs.nixfmt-tree;
formatter.${system} = nixpkgs.legacyPackages.${system}.nixfmt-tree;
};
}

View File

@ -3,16 +3,14 @@
lib,
pkgs,
profile,
username,
...
}:
with lib;
let
gpgCfg = config.modules.gpg;
let gpgCfg = config.modules.gpg;
in
{
imports = [
../../modules/home
../../modules/homes
../../modules/options
../../profiles/${profile}
];
@ -21,13 +19,9 @@ in
modules.shell.defaultShell = "zsh";
home = {
inherit username;
homeDirectory = "/home/${username}";
username = "josh";
homeDirectory = "/home/josh";
stateVersion = "25.11";
sessionVariables = {
EDITOR = "vim";
VISUAL = "vim";
};
packages = with pkgs; [
git
@ -56,4 +50,24 @@ in
# Let Home Manager install and manage itself
programs.home-manager.enable = true;
nix = {
package = mkDefault pkgs.nix;
settings = {
allowed-users = [ "josh" ];
trusted-users = [ "root" "@wheel" "josh" ];
experimental-features = [
"nix-command"
"flakes"
];
extra-substituters = [
"https://walker.cachix.org"
"https://walker-git.cachix.org"
];
extra-trusted-public-keys = [
"walker.cachix.org-1:fG8q+uAaMqhsMxWjwvk0IMb4mFPFLqHjuvfwQxE4oJM="
"walker-git.cachix.org-1:vmC0ocfPWh0S/vRAQGtChuiZBTAe4wiKDeyyXM0/7pM="
];
};
};
}

View File

@ -5,7 +5,7 @@
imports = [
../../profiles/desktop
../../modules/nixos
../../modules/core
../../modules/drivers
../../modules/options

View File

@ -5,7 +5,7 @@
imports = [
../../profiles/desktop
../../modules/nixos
../../modules/core
../../modules/drivers
../../modules/options

View File

@ -5,7 +5,7 @@
imports = [
../../profiles/desktop
../../modules/nixos
../../modules/core
../../modules/drivers
../../modules/options
@ -24,5 +24,5 @@
# drivers.nvidia.enable = false;
# drivers.nvidia-prime.enable = false;
# drivers.intel.enable = false;
modules.vm.guestServices.enable = true;
vm.guest-services.enable = true;
}

View File

@ -7,7 +7,7 @@
loader.systemd-boot = {
enable = true;
configurationLimit = 10;
consoleMode = config.modules.system.systemdBootConsoleMode;
consoleMode = config.system.systemdBootConsoleMode;
};
loader.efi.canTouchEfiVariables = true;
};

View File

@ -4,10 +4,10 @@
{
imports = [
./boot.nix
./firefox.nix
./fonts.nix
./gdm.nix
./gnomeBoxes.nix
./home-manager.nix
./hyprland.nix
./localsend.nix
./network.nix

22
modules/core/firefox.nix Normal file
View File

@ -0,0 +1,22 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
pipewireCfg = config.modules.pipewire;
in
{
# Add wayland screensharing support if PipeWire is enabled
environment.systemPackages =
with pkgs;
[ ]
++ (
if pipewireCfg.enable then
[ (wrapFirefox (firefox-unwrapped.override { pipewireSupport = true; }) { }) ]
else
[ firefox ]
);
}

View File

@ -5,10 +5,10 @@
}:
with lib;
let
cfg = config.modules.display;
cfg = config.modules.displayManager;
in
{
config = mkIf (cfg.manager == "gdm") {
config = mkIf (cfg.displayManager == "gdm") {
services.displayManager.gdm = {
enable = true;
};

18
modules/core/packages.nix Normal file
View File

@ -0,0 +1,18 @@
{
pkgs,
...
}:
{
programs = {
};
environment.systemPackages = with pkgs; [
git
home-manager
tldr
tmux
vim-full
wl-clipboard
];
}

View File

@ -5,10 +5,10 @@
}:
with lib;
let
cfg = config.modules.display;
cfg = config.modules.displayManager;
in
{
config = mkIf (cfg.manager == "sddm") {
config = mkIf (cfg.displayManager == "sddm") {
services.displayManager.sddm = {
enable = true;
wayland.enable = true;

View File

@ -1,31 +1,17 @@
{
config,
username,
...
}:
let
cfg = config.modules.system;
cfg = config.system;
in
{
nix = {
settings = {
allowed-users = [ username ];
trusted-users = [
"@wheel"
username
];
experimental-features = [
"nix-command"
"flakes"
];
extra-substituters = [
"https://walker.cachix.org"
"https://walker-git.cachix.org"
];
extra-trusted-public-keys = [
"walker.cachix.org-1:fG8q+uAaMqhsMxWjwvk0IMb4mFPFLqHjuvfwQxE4oJM="
"walker-git.cachix.org-1:vmC0ocfPWh0S/vRAQGtChuiZBTAe4wiKDeyyXM0/7pM="
];
};
};

View File

@ -2,12 +2,13 @@
config,
host,
inputs,
homePath,
pkgs,
profile,
username,
...
}:
let
shellCfg = config.modules.shell;
zshCfg = config.modules.zsh;
in
{
@ -25,19 +26,34 @@ in
;
};
users.${username} = {
imports = [ homePath ];
imports = [ ../../homes/${username}/home.nix ];
modules.gpg.signingKey = config.modules.gpg.signingKey;
modules.display.scale = config.modules.display.scale;
};
};
users.mutableUsers = true;
users.users.${username} = {
isNormalUser = true;
initialPassword = "changeme";
extraGroups = [
"networkmanager"
"wheel"
];
shell = pkgs.${shellCfg.defaultShell};
ignoreShellProgramCheck = true;
packages = with pkgs; [
];
};
# Set /etc/shells so GDM will show our user when ZSH is selected
environment.shells = [ pkgs.${shellCfg.defaultShell} ];
environment.pathsToLink =
# Since Home Manager is installed via its NixOS module, we need to add this so that
# the portal definitions and DE provided configurations get linked
[
"/share/applications"
"/share/xdg-desktop-portal"
]
[ "/share/applications" "/share/xdg-desktop-portal" ]
# Needed to get completion for system packages (e.g. systemd)
++ (if zshCfg.enable then [ "/share/zsh" ] else [ ]);
}

View File

@ -5,9 +5,13 @@
}:
with lib;
let
cfg = config.modules.vm.guestServices;
cfg = config.vm.guest-services;
in
{
options.vm.guest-services = {
enable = mkEnableOption "Enable Virtual Machine Guest Services";
};
config = mkIf cfg.enable {
services.qemuGuest.enable = true;
services.spice-vdagentd.enable = true;

View File

@ -1,101 +0,0 @@
{
config,
pkgs,
username,
...
}:
{
programs.firefox = {
enable = true;
package = pkgs.firefox;
configPath = "${config.xdg.configHome}/mozilla/firefox";
policies = {
# Updates & Background Services
AppAutoUpdate = false;
BackgroundAppUpdate = false;
# Quality of Life
OfferToSaveLogins = false;
# Extensions
ExtensionSettings =
let
moz = short: "https://addons.mozilla.org/firefox/downloads/latest/${short}/latest.xpi";
in
{
"*".installation_mode = "blocked";
# uBlock Origin
"uBlock0@raymondhill.net" = {
install_url = moz "ublock-origin";
installation_mode = "force_installed";
updates_disabled = true;
private_browsing = true;
default_area = "navbar";
};
# Bitwarden
"{446900e4-71c2-419f-a6a7-df9c091e268b}" = {
install_url = moz "bitwarden-password-manager";
installation_mode = "force_installed";
updates_disabled = true;
private_browsing = true;
default_area = "navbar";
};
# Dark Reader
"addon@darkreader.org" = {
install_url = moz "darkreader";
installation_mode = "force_installed";
updates_disabled = true;
private_browsing = true;
default_area = "navbar";
};
# SponsorBlock
"sponsorBlocker@ajay.app" = {
install_url = moz "sponsorblock";
installation_mode = "force_installed";
updates_disabled = true;
private_browsing = true;
default_area = "menupanel";
};
# Return YouTube Dislike
"{762f9885-5a13-4abd-9c77-433dcd38b8fd}" = {
install_url = moz "return-youtube-dislikes";
installation_mode = "force_installed";
updates_disabled = true;
private_browsing = true;
default_area = "menupanel";
};
# RES
"jid1-xUfzOsOFlzSOXg@jetpack" = {
install_url = moz "reddit-enhancement-suite";
installation_mode = "force_installed";
updates_disabled = true;
private_browsing = true;
default_area = "menupanel";
};
};
"3rdparty".Extensions = {
"{446900e4-71c2-419f-a6a7-df9c091e268b}" = {
environment = {
base = "https://bitwarden.joshuayuen.me";
};
};
};
profiles = {
${username} = {
id = 0;
isDefault = true;
name = "${username}";
};
};
};
};
}

View File

@ -1,107 +0,0 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.modules.zsh;
xdgCfg = config.xdg;
in
{
imports = [
./completion.nix
./p10k.nix
];
programs.zsh = {
enable = cfg.enable;
dotDir = "${xdgCfg.configHome}/zsh";
autosuggestion.enable = false;
enableCompletion = false;
syntaxHighlighting = {
enable = true;
highlighters = [
"main"
"brackets"
"pattern"
"root"
];
};
historySubstringSearch.enable = true;
history = {
append = true;
ignoreDups = false;
ignoreSpace = true;
save = 100000;
share = true;
size = 100000;
extended = true;
};
initContent =
let
zshConfigInitEarly = mkOrder 500 ''
# p10k
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh" ]]; then
source "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh"
fi
source "${xdgCfg.configHome}/zsh/p10k.zsh";
'';
zshConfig = mkOrder 1000 ''
# Autocompletion and menu styling
zmodload zsh/complist
autoload -Uz compinit && compinit
source "${xdgCfg.configHome}/zsh/completion.zsh";
# vi keybindings for menu select
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'j' vi-down-line-or-history
bindkey -M menuselect 'l' vi-forward-char
# Tab to accept current selection
bindkey -M menuselect '^I' accept-and-infer-next-history
# Control arrow keys
bindkey '^[[1;5C' forward-word
bindkey '^[[1;5D' backward-word
# Control backspace
bindkey '^H' backward-kill-word
'';
in
mkMerge [
zshConfigInitEarly
zshConfig
];
shellAliases = {
".." = "cd ..";
"..." = "cd ../..";
ls = "ls --color=auto";
ll = "ls -al";
grep = "grep --color=auto";
back = "cd $OLDPWD";
gs = "git status";
ssha = "eval $(ssh-agent) && ssh-add";
};
plugins = [
{
name = "powerlevel10k";
src = "${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/";
file = "powerlevel10k.zsh-theme";
}
{
name = "zsh-autocomplete";
src = "${pkgs.zsh-autocomplete}/share/zsh-autocomplete/";
file = "zsh-autocomplete.zsh";
}
];
};
}

99
modules/homes/firefox.nix Normal file
View File

@ -0,0 +1,99 @@
{
config,
pkgs,
username,
...
}:
{
programs.firefox = {
enable = true;
package = pkgs.firefox;
configPath = "${config.xdg.configHome}/mozilla/firefox";
policies = {
# Updates & Background Services
AppAutoUpdate = false;
BackgroundAppUpdate = false;
# Quality of Life
OfferToSaveLogins = false;
# Extensions
ExtensionSettings = let
moz = short: "https://addons.mozilla.org/firefox/downloads/latest/${short}/latest.xpi";
in {
"*".installation_mode = "blocked";
# uBlock Origin
"uBlock0@raymondhill.net" = {
install_url = moz "ublock-origin";
installation_mode = "force_installed";
updates_disabled = true;
private_browsing = true;
default_area = "navbar";
};
# Bitwarden
"{446900e4-71c2-419f-a6a7-df9c091e268b}" = {
install_url = moz "bitwarden-password-manager";
installation_mode = "force_installed";
updates_disabled = true;
private_browsing = true;
default_area = "navbar";
};
# Dark Reader
"addon@darkreader.org" = {
install_url = moz "darkreader";
installation_mode = "force_installed";
updates_disabled = true;
private_browsing = true;
default_area = "navbar";
};
# SponsorBlock
"sponsorBlocker@ajay.app" = {
install_url = moz "sponsorblock";
installation_mode = "force_installed";
updates_disabled = true;
private_browsing = true;
default_area = "menupanel";
};
# Return YouTube Dislike
"{762f9885-5a13-4abd-9c77-433dcd38b8fd}" = {
install_url = moz "return-youtube-dislikes";
installation_mode = "force_installed";
updates_disabled = true;
private_browsing = true;
default_area = "menupanel";
};
# RES
"jid1-xUfzOsOFlzSOXg@jetpack" = {
install_url = moz "reddit-enhancement-suite";
installation_mode = "force_installed";
updates_disabled = true;
private_browsing = true;
default_area = "menupanel";
};
};
"3rdparty".Extensions = {
"{446900e4-71c2-419f-a6a7-df9c091e268b}" = {
environment = {
base = "https://bitwarden.joshuayuen.me";
};
};
};
profiles = {
${username} = {
id = 0;
isDefault = true;
name = "${username}";
};
};
};
};
}

View File

@ -5,8 +5,7 @@
...
}:
with lib;
let
hyprlandCfg = config.modules.hyprland;
let hyprlandCfg = config.modules.hyprland;
in
{
imports = [ inputs.walker.homeManagerModules.default ];

View File

@ -0,0 +1,103 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.modules.zsh;
xdgCfg = config.xdg;
in
{
imports = [
./completion.nix
./p10k.nix
];
programs.zsh = {
enable = cfg.enable;
dotDir = "${xdgCfg.configHome}/zsh";
autosuggestion.enable = false;
enableCompletion = false;
syntaxHighlighting = {
enable = true;
highlighters = [
"main"
"brackets"
"pattern"
"root"
];
};
historySubstringSearch.enable = true;
history = {
append = true;
ignoreDups = false;
ignoreSpace = true;
save = 100000;
share = true;
size = 100000;
extended = true;
};
initContent =
let
zshConfigInitEarly = mkOrder 500 ''
# p10k
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh" ]]; then
source "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh"
fi
source "${xdgCfg.configHome}/zsh/p10k.zsh";
'';
zshConfig = mkOrder 1000 ''
# Autocompletion and menu styling
zmodload zsh/complist
autoload -Uz compinit && compinit
source "${xdgCfg.configHome}/zsh/completion.zsh";
# vi keybindings for menu select
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'j' vi-down-line-or-history
bindkey -M menuselect 'l' vi-forward-char
# Tab to accept current selection
bindkey -M menuselect '^I' accept-and-infer-next-history
# Control arrow keys
bindkey '^[[1;5C' forward-word
bindkey '^[[1;5D' backward-word
# Control backspace
bindkey '^H' backward-kill-word
'';
in mkMerge [ zshConfigInitEarly zshConfig ];
shellAliases = {
".." = "cd ..";
"..." = "cd ../..";
ls = "ls --color=auto";
ll = "ls -al";
grep = "grep --color=auto";
back = "cd $OLDPWD";
gs = "git status";
ssha = "eval $(ssh-agent) && ssh-add";
};
plugins = [
{
name = "powerlevel10k";
src = "${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/";
file = "powerlevel10k.zsh-theme";
}
{
name = "zsh-autocomplete";
src = "${pkgs.zsh-autocomplete}/share/zsh-autocomplete/";
file = "zsh-autocomplete.zsh";
}
];
};
}

View File

@ -1,5 +0,0 @@
{
...
}:
{
}

View File

@ -1,28 +0,0 @@
{
config,
pkgs,
username,
...
}:
let
shellCfg = config.modules.shell;
in
{
users.mutableUsers = true;
users.users.${username} = {
isNormalUser = true;
initialPassword = "changeme";
extraGroups = [
"networkmanager"
"wheel"
];
shell = pkgs.${shellCfg.defaultShell};
ignoreShellProgramCheck = true;
packages = with pkgs; [
];
};
# Set /etc/shells so GDM will show our user when ZSH is selected
environment.shells = [ pkgs.${shellCfg.defaultShell} ];
}

View File

@ -5,6 +5,7 @@
imports = [
./discord.nix
./display.nix
./displayManager.nix
./gnomeBoxes.nix
./gpg.nix
./hyprland.nix
@ -14,7 +15,6 @@
./shell.nix
./system.nix
./tailscale.nix
./vm.nix
./zsh.nix
];
}

View File

@ -5,17 +5,6 @@
with lib;
{
options.modules.display = {
manager = mkOption {
type = types.enum [
"gdm"
"sddm"
];
default = "sddm";
description = ''
The display manager to use.
'';
};
scale = mkOption {
type = types.int;
default = 1;

View File

@ -0,0 +1,19 @@
{
lib,
...
}:
with lib;
{
options.modules.displayManager = {
displayManager = mkOption {
type = types.enum [
"gdm"
"sddm"
];
default = "sddm";
description = ''
The display manager to use.
'';
};
};
}

View File

@ -4,7 +4,7 @@
}:
with lib;
{
options.modules.system = {
options.system = {
locale = mkOption {
type = types.str;
default = "en_US.UTF-8";

View File

@ -1,12 +0,0 @@
{
lib,
...
}:
with lib;
{
options.modules.vm = {
guestServices = {
enable = mkEnableOption "Virtual Machine guest services";
};
};
}

View File

@ -2,6 +2,10 @@
...
}:
{
imports = [
../../modules/options
];
modules.hyprland = {
enable = true;
terminal = "kitty";
@ -11,7 +15,7 @@
];
};
modules.plasma.enable = false;
modules.display.manager = "gdm";
modules.displayManager.displayManager = "gdm";
modules.localsend.enable = true;

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash
#/usr/bin/env bash
echo "Removing old qcow2 disk ..."
rm -f ./vm.qcow2