WSL + more modularity

This commit is contained in:
System administrator 2024-01-30 04:25:25 +00:00 committed by Bryan Ramos
parent 7b63b3b04f
commit e513913099
Signed by: bryan
GPG key ID: 6ABDCD144D6643C8
57 changed files with 356 additions and 92 deletions

73
flake.lock generated
View file

@ -1,5 +1,39 @@
{ {
"nodes": { "nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"home-manager": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -21,6 +55,29 @@
"type": "github" "type": "github"
} }
}, },
"nixos-wsl": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1702823833,
"narHash": "sha256-Sreo1VEMSwS/T83QxXeN1cDtgXWXPMibGYfQ8pLLSVc=",
"owner": "nix-community",
"repo": "NixOS-WSL",
"rev": "34eda458bd3f6bad856a99860184d775bc1dd588",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "2311.5.3",
"repo": "NixOS-WSL",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1705916986, "lastModified": 1705916986,
@ -40,8 +97,24 @@
"root": { "root": {
"inputs": { "inputs": {
"home-manager": "home-manager", "home-manager": "home-manager",
"nixos-wsl": "nixos-wsl",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -7,9 +7,13 @@
url = "github:nix-community/home-manager/release-23.11"; url = "github:nix-community/home-manager/release-23.11";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
nixos-wsl = {
url = "github:nix-community/NixOS-WSL/2311.5.3";
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
outputs = { self, nixpkgs, home-manager }: outputs = { self, nixpkgs, home-manager, nixos-wsl }:
let let
system = "x86_64-linux"; system = "x86_64-linux";
pkgs = import nixpkgs { pkgs = import nixpkgs {
@ -24,12 +28,40 @@
nixosConfigurations.desktop = nixpkgs.lib.nixosSystem { nixosConfigurations.desktop = nixpkgs.lib.nixosSystem {
inherit system pkgs; inherit system pkgs;
modules = [ modules = [
./sysConfig/desktop ./src/systems/desktop
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
{ {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
home-manager.users.bryan = import ./homeConfig/home.nix; home-manager.users.bryan = import ./src/systems/desktop/home.nix;
}
];
};
nixosConfigurations.windows = nixpkgs.lib.nixosSystem {
inherit system pkgs;
modules = [
./src/systems/wsl
nixos-wsl.nixosModules.wsl
{
wsl = {
enable = true;
defaultUser = nixpkgs.lib.mkDefault "bryan";
nativeSystemd = true;
wslConf = {
boot.command = "cd";
network = {
hostname = "plato";
generateHosts = true;
};
};
};
}
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.bryan = import ./src/systems/wsl/home.nix;
} }
]; ];
}; };

View file

@ -1,21 +0,0 @@
{ config, ... }:
{
programs.home-manager.enable = true;
imports = [ ./modules ../user ];
home.stateVersion = "22.11";
home.username = "${config.user.name}";
home.homeDirectory = "/home/${config.user.name}";
modules = {
bash.enable = true;
git.enable = true;
gpg.enable = true;
gui.enable = true;
security.enable = true;
utils.enable = true;
};
}

View file

@ -1,3 +0,0 @@
{
nixup = "sudo nixos-rebuild switch --flake /etc/nixos/.#desktop";
}

View file

@ -1,19 +0,0 @@
{ pkgs, lib, config, ... }:
with lib;
let
cfg = config.modules.vim;
in
{ options.modules.vim = { enable = mkEnableOption "vim"; };
config = mkIf cfg.enable {
programs.vim = {
enable = true;
package = pkgs.vim;
extraConfig = import ./config/vimrc;
};
programs.bash.shellAliases = {
vi = "${pkgs.vim}/bin/vim";
};
};
}

View file

@ -0,0 +1,3 @@
{
cd = "cd -L";
}

View file

@ -2,10 +2,10 @@
with lib; with lib;
let let
cfg = config.modules.alacritty; cfg = config.modules.gui.alacritty;
in in
{ options.modules.alacritty = { enable = mkEnableOption "alacritty"; }; { options.modules.gui.alacritty = { enable = mkEnableOption "gui.alacritty"; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.alacritty = { programs.alacritty = {
enable = true; enable = true;

View file

@ -2,10 +2,10 @@
with lib; with lib;
let let
cfg = config.modules.browsers; cfg = config.modules.gui.browsers;
in in
{ options.modules.browsers = { enable = mkEnableOption "browsers"; }; { options.modules.gui.browsers = { enable = mkEnableOption "gui.browsers"; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.firefox.enable = true; programs.firefox.enable = true;

View file

@ -2,10 +2,10 @@
with lib; with lib;
let let
cfg = config.modules.corn; cfg = config.modules.gui.corn;
in in
{ options.modules.corn = { enable = mkEnableOption "corn"; }; { options.modules.gui.corn = { enable = mkEnableOption "gui.corn"; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = with pkgs; [ home.packages = with pkgs; [
trezor-suite trezor-suite

View file

@ -4,7 +4,8 @@
./browsers ./browsers
./corn ./corn
./fun ./fun
./guiUtils ./utils
./neovim ./neovim
./writing
]; ];
} }

View file

@ -2,10 +2,10 @@
with lib; with lib;
let let
cfg = config.modules.fun; cfg = config.modules.gui.fun;
in in
{ options.modules.fun = { enable = mkEnableOption "fun"; }; { options.modules.gui.fun = { enable = mkEnableOption "gui.fun"; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.obs-studio = { programs.obs-studio = {
enable = true; enable = true;

View file

@ -2,10 +2,10 @@
with lib; with lib;
let let
cfg = config.modules.neovim; cfg = config.modules.gui.neovim;
in in
{ options.modules.neovim = { enable = mkEnableOption "neovim"; }; { options.modules.gui.neovim = { enable = mkEnableOption "gui.neovim"; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.neovim = { programs.neovim = {
enable = true; enable = true;

View file

@ -2,10 +2,10 @@
with lib; with lib;
let let
cfg = config.modules.guiUtils; cfg = config.modules.gui.utils;
in in
{ options.modules.guiUtils = { enable = mkEnableOption "guiUtils"; }; { options.modules.gui.utils = { enable = mkEnableOption "gui.utils"; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.btop.enable = true; programs.btop.enable = true;
home.packages = with pkgs; [ home.packages = with pkgs; [

View file

@ -0,0 +1,17 @@
{ pkgs, lib, config, ... }:
with lib;
let
cfg = config.modules.gui.writing;
in
{ options.modules.gui.writing = { enable = mkEnableOption "gui.writing"; };
config = mkIf cfg.enable {
home.packages = with pkgs; [
mdbook
texlive.combined.scheme-tetex
pandoc
asciidoctor
];
};
}

View file

@ -55,14 +55,5 @@ in
}; };
fonts.fontconfig.enable = true; fonts.fontconfig.enable = true;
modules = {
alacritty.enable = true;
browsers.enable = true;
corn.enable = true;
fun.enable = true;
guiUtils.enable = true;
neovim.enable = true;
};
}; };
} }

View file

@ -8,19 +8,11 @@ in
{ options.modules.utils = { enable = mkEnableOption "utils"; }; { options.modules.utils = { enable = mkEnableOption "utils"; };
imports = [ ./modules ]; imports = [ ./modules ];
config = mkIf cfg.enable { config = mkIf cfg.enable {
modules = {
vim.enable = false;
email.enable = true;
irc.enable = true;
dev.enable = true;
};
home.packages = with pkgs; [ home.packages = with pkgs; [
wget curl tree neofetch wget curl tree neofetch
unzip fping calc qrencode unzip fping calc qrencode
fd pkg-config pciutils fd pkg-config pciutils
mdbook rsync pandoc texlive.combined.scheme-tetex rsync zip
zip asciidoctor
]; ];
}; };
} }

View file

@ -2,10 +2,10 @@
with lib; with lib;
let let
cfg = config.modules.dev; cfg = config.modules.utils.dev;
in in
{ options.modules.dev = { enable = mkEnableOption "dev"; }; { options.modules.utils.dev = { enable = mkEnableOption "utils.dev"; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = with pkgs; [ home.packages = with pkgs; [
nix-init nix-init

View file

@ -2,10 +2,10 @@
with lib; with lib;
let let
cfg = config.modules.email; cfg = config.modules.utils.email;
in in
{ options.modules.email = { enable = mkEnableOption "email"; }; { options.modules.utils.email = { enable = mkEnableOption "utils.email"; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.aerc = { programs.aerc = {
enable = true; enable = true;

View file

@ -2,10 +2,10 @@
with lib; with lib;
let let
cfg = config.modules.irc; cfg = config.modules.utils.irc;
in in
{ options.modules.irc = { enable = mkEnableOption "irc"; }; { options.modules.utils.irc = { enable = mkEnableOption "utils.irc"; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = with pkgs; [ home.packages = with pkgs; [
weechat weechat

View file

@ -14,14 +14,14 @@ autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
call plug#begin('~/.vim/plugged') call plug#begin('~/.vim/plugged')
Plug 'joshdick/onedark.vim' Plug 'joshdick/onedark.vim'
Plug 'tpope/vim-surround' Plug 'tpope/vim-surround'
Plug 'jiangmiao/auto-pairs' Plug 'jiangmiao/auto-pairs'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim' Plug 'junegunn/fzf.vim'
Plug 'mtdl9/vim-log-highlighting' Plug 'mtdl9/vim-log-highlighting'
Plug 'machakann/vim-highlightedyank' Plug 'machakann/vim-highlightedyank'
Plug 'itchyny/lightline.vim' Plug 'itchyny/lightline.vim'
call plug#end() call plug#end()
@ -34,17 +34,23 @@ let g:highlightedyank_highlight_duration = 80
let g:lightline = { 'colorscheme': 'one', } let g:lightline = { 'colorscheme': 'one', }
set laststatus=2 set laststatus=2
set number set number
set relativenumber set relativenumber
set cursorline
set noincsearch set noincsearch
set clipboard=unnamedplus
set ignorecase set ignorecase
set clipboard=unnamedplus
set noswapfile set noswapfile
set tabstop=2 set tabstop=2
set shiftwidth=2 set shiftwidth=2
set expandtab set expandtab
highlight CursorLine ctermbg=NONE guibg=NONE
highlight CursorLineNr ctermfg=magenta guifg=magenta
highlight HighlightedyankRegion ctermfg=NONE guifg=NONE highlight HighlightedyankRegion ctermfg=NONE guifg=NONE
highlight Normal ctermbg=NONE guibg=NONE highlight Normal ctermbg=NONE guibg=NONE
highlight NormalNC ctermbg=NONE guibg=NONE highlight NormalNC ctermbg=NONE guibg=NONE
@ -56,6 +62,7 @@ vnoremap > >gv
nnoremap <C-U> <C-U>zz nnoremap <C-U> <C-U>zz
nnoremap <C-D> <C-D>zz nnoremap <C-D> <C-D>zz
nnoremap <leader>e :Explore<CR>
nnoremap <leader><ESC> :noh<CR> nnoremap <leader><ESC> :noh<CR>
nnoremap <leader>/ :Rg<Space> nnoremap <leader>/ :Rg<Space>
nnoremap <Leader>ts :execute "normal! a" . strftime('[%b %d %H:%M:%S - BR]')<CR> nnoremap <Leader>ts :execute "normal! a" . strftime('[%b %d %H:%M:%S - BR]')<CR>

View file

@ -0,0 +1,22 @@
{ pkgs, lib, config, ... }:
with lib;
let
cfg = config.modules.utils.vim;
in
{ options.modules.utils.vim = { enable = mkEnableOption "utils.vim"; };
config = mkIf cfg.enable {
home = {
packages = with pkgs; [
vim
];
file.".config/.vimrc" = {
source = ./config/vimrc;
};
};
programs.bash.shellAliases = {
vi = "${pkgs.vim}/bin/vim";
};
};
}

View file

@ -1,3 +1,5 @@
{ lib, pkgs, ... }:
{ {
imports = [ imports = [
../../user ../../user

View file

@ -0,0 +1,43 @@
{ config, ... }:
{
programs.home-manager.enable = true;
programs.bash.shellAliases = {
nixup = "sudo nixos-rebuild switch --flake /etc/nixos/.#desktop";
};
imports = [
../../modules
../../user
];
home.stateVersion = "22.11";
home.username = "${config.user.name}";
home.homeDirectory = "/home/${config.user.name}";
modules = {
bash.enable = true;
git.enable = true;
gpg.enable = true;
security.enable = true;
utils = {
enable = true;
dev.enable = true;
irc.enable = true;
vim.enable = false;
};
gui = {
enable = true;
alacritty.enable = true;
browsers.enable = true;
corn.enable = true;
fun.enable = true;
neovim.enable = true;
utils.enable = true;
writing.enable = true;
};
};
}

View file

@ -0,0 +1,8 @@
{ lib, ... }:
{
imports = [
../../user
./system.nix
];
}

33
src/systems/wsl/home.nix Normal file
View file

@ -0,0 +1,33 @@
{ config, ... }:
{
programs.home-manager.enable = true;
programs.bash.shellAliases = {
nixup = "sudo nixos-rebuild switch --flake .#windows";
};
imports = [
../../modules
../../user
];
home.stateVersion = "23.11";
home.username = "${config.user.name}";
home.homeDirectory = "/home/${config.user.name}";
modules = {
bash.enable = true;
git.enable = true;
gpg.enable = true;
gui.enable = false;
security.enable = true;
utils = {
enable = true;
dev.enable = true;
email.enable = true;
irc.enable = true;
vim.enable = true;
};
};
}

View file

@ -0,0 +1,83 @@
{ pkgs, lib, config, ... }:
{ system.stateVersion = "23.11";
# Users
users.users = {
${config.user.name} = {
isNormalUser = true;
extraGroups = config.user.groups;
openssh.authorizedKeys.keys = config.user.sshKeys;
};
};
boot.isContainer = true;
# Nix
nix = {
channel.enable = false;
package = pkgs.nixFlakes;
extraOptions = "experimental-features = nix-command flakes";
settings = {
auto-optimise-store = true;
trusted-users = [ "${config.user.name}" ];
};
gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 30d";
};
};
# Sudo Options
security.sudo = {
wheelNeedsPassword = false;
execWheelOnly = true;
};
# System Services
services = {
cron = {
enable = true;
systemCronJobs = [];
};
};
# Locale
time = {
timeZone = "America/New_York";
};
services.timesyncd = {
enable = true;
servers = [
"0.pool.ntp.org"
"1.pool.ntp.org"
"2.pool.ntp.org"
"3.pool.ntp.org"
];
};
i18n.defaultLocale = "en_US.UTF-8";
console = {
font = "Lat2-Terminus16";
useXkbConfig = true;
};
# Networking
networking = {
useDHCP = lib.mkDefault true;
firewall = {
enable = true;
allowedTCPPorts = [ 22 80 443 ];
};
};
services.openssh = {
enable = true;
startWhenNeeded = true;
settings = {
X11Forwarding = false;
PasswordAuthentication = false;
};
};
}