Add LSP and formatter

This commit is contained in:
Joshua Yuen 2025-08-22 08:46:56 -04:00
parent 8998c1078b
commit c3cc521997
Signed by: josh
GPG Key ID: 502720BC22ED411C
39 changed files with 261 additions and 213 deletions

45
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,45 @@
{
// Nix settings
"nix.formatterPath": [
"nixpkgs-fmt",
"nixfmt",
"treefmt",
"--stdin",
"{file}",
"nix",
"fmt",
"--",
"-",
],
"nix.enableLanguageServer": true,
"nix.serverPath": "nixd",
"nix.serverSettings": {
"nixd": {
"nixpkgs": {
"expr": "(builtins.getFlake \"${workspaceFolder}/flake.nix\").inputs.nixpkgs { }"
},
"formatting": {
"command": [
"nix fmt"
]
},
"options": {
"nixos": {
"expr": "(builtins.getFlake (builtins.toString ./.)).nixosConfigurations.nixos.options"
},
"live": {
"expr": "(builtins.getFlake (builtins.toString ./.)).nixosConfigurations.live.options"
},
"nixosvm": {
"expr": "(builtins.getFlake (builtins.toString ./.)).nixosConfigurations.nixosvm.options"
},
// "home-manager": {
// "expr": "(builtins.getFlake \"/absolute/path/to/flake\").homeConfigurations.<name>.options"
// },
}
}
},
"nixEnvSelector.useFlakes": true,
"nixEnvSelector.suggestion": true,
"nixEnvSelector.nixFile": "${workspaceFolder}/flake.nix",
}

View File

@ -18,12 +18,20 @@
}; };
}; };
outputs = { nixpkgs, home-manager, install-system, ... } @ inputs: let outputs =
{
nixpkgs,
home-manager,
install-system,
...
}@inputs:
let
system = "x86_64-linux"; system = "x86_64-linux";
host = "vm"; host = "vm";
profile = "vm"; profile = "vm";
username = "josh"; username = "josh";
in { in
{
nixosConfigurations = { nixosConfigurations = {
nixos = nixpkgs.lib.nixosSystem { nixos = nixpkgs.lib.nixosSystem {
inherit system; inherit system;
@ -66,5 +74,13 @@
]; ];
}; };
}; };
devShell.${system} = nixpkgs.legacyPackages.${system}.pkgs.mkShell {
packages = with nixpkgs.legacyPackages.${system}.pkgs; [
nixd
];
};
formatter.${system} = nixpkgs.legacyPackages.${system}.nixfmt-tree;
}; };
} }

View File

@ -14,8 +14,13 @@ in
}; };
# Add wayland screensharing support if PipeWire is enabled # Add wayland screensharing support if PipeWire is enabled
environment.systemPackages = with pkgs; [] environment.systemPackages =
++ (if pipewireCfg.enable with pkgs;
then [ (wrapFirefox (firefox-unwrapped.override { pipewireSupport = true; }) {}) ] [ ]
else [ firefox ]); ++ (
if pipewireCfg.enable then
[ (wrapFirefox (firefox-unwrapped.override { pipewireSupport = true; }) { }) ]
else
[ firefox ]
);
} }

View File

@ -6,13 +6,14 @@
{ {
fonts = { fonts = {
fontconfig.enable = true; fontconfig.enable = true;
packages = with pkgs; [ packages =
with pkgs;
[
font-awesome font-awesome
montserrat montserrat
nerd-fonts.jetbrains-mono nerd-fonts.jetbrains-mono
noto-fonts-emoji noto-fonts-emoji
] ++ (if config.modules.zsh.enable ]
then [ nerd-fonts.meslo-lg ] ++ (if config.modules.zsh.enable then [ nerd-fonts.meslo-lg ] else [ ]);
else []);
}; };
} }

View File

@ -1,5 +1,4 @@
{ {
config,
host, host,
pkgs, pkgs,
... ...

View File

@ -1,5 +1,4 @@
{ {
config,
pkgs, pkgs,
... ...
}: }:

View File

@ -1,9 +1,7 @@
{ {
config, config,
lib,
... ...
}: }:
with lib;
let let
cfg = config.system; cfg = config.system;
in in

View File

@ -2,13 +2,11 @@
config, config,
host, host,
inputs, inputs,
lib,
pkgs, pkgs,
profile, profile,
username, username,
... ...
}: }:
with lib;
let let
shellCfg = config.modules.shell; shellCfg = config.modules.shell;
in in
@ -18,7 +16,14 @@ in
useUserPackages = true; useUserPackages = true;
useGlobalPkgs = false; useGlobalPkgs = false;
backupFileExtension = "backup"; backupFileExtension = "backup";
extraSpecialArgs = { inherit host inputs profile username; }; extraSpecialArgs = {
inherit
host
inputs
profile
username
;
};
users.${username} = { users.${username} = {
imports = [ ./../home ]; imports = [ ./../home ];
home = { home = {
@ -42,7 +47,7 @@ in
}; };
# Set /etc/shells so GDM will show our user when ZSH is selected # Set /etc/shells so GDM will show our user when ZSH is selected
environment.shells = with pkgs; [ pkgs.${shellCfg.defaultShell} ]; environment.shells = [ pkgs.${shellCfg.defaultShell} ];
nix.settings.allowed-users = [ "${username}" ]; nix.settings.allowed-users = [ "${username}" ];
} }

View File

@ -1,7 +1,6 @@
{ {
config, config,
lib, lib,
pkgs,
... ...
}: }:
with lib; with lib;

View File

@ -1,5 +1,4 @@
{ {
host,
... ...
}: }:
{ {

View File

@ -1,9 +1,7 @@
{ {
lib,
osConfig, osConfig,
... ...
}: }:
with lib;
let let
cfg = osConfig.modules.hyprland; cfg = osConfig.modules.hyprland;
in in

View File

@ -1,5 +1,4 @@
{ {
host,
lib, lib,
osConfig, osConfig,
pkgs, pkgs,

View File

@ -1,5 +1,4 @@
{ {
config,
lib, lib,
osConfig, osConfig,
pkgs, pkgs,

View File

@ -1,10 +1,8 @@
{ {
lib,
osConfig, osConfig,
pkgs, pkgs,
... ...
}: }:
with lib;
let let
hyprlandCfg = osConfig.modules.hyprland; hyprlandCfg = osConfig.modules.hyprland;
pipewireCfg = osConfig.modules.pipewire; pipewireCfg = osConfig.modules.pipewire;
@ -17,27 +15,31 @@ in
mimeApps.enable = true; mimeApps.enable = true;
portal = { portal = {
enable = true; enable = true;
extraPortals = [] extraPortals =
++ (if hyprlandCfg.enable [ ]
then [ pkgs.xdg-desktop-portal-hyprland ] ++ (if hyprlandCfg.enable then [ pkgs.xdg-desktop-portal-hyprland ] else [ ])
else []) ++ (
++ (if pipewireCfg.enable if pipewireCfg.enable then
then [ [
pkgs.xdg-desktop-portal-wlr pkgs.xdg-desktop-portal-wlr
pkgs.xdg-desktop-portal-gtk pkgs.xdg-desktop-portal-gtk
] ]
else []) else
++ (if plasmaCfg.enable [ ]
then [ pkgs.kdePackages.xdg-desktop-portal-kde ] )
else []); ++ (if plasmaCfg.enable then [ pkgs.kdePackages.xdg-desktop-portal-kde ] else [ ]);
configPackages = [] configPackages =
++ (if hyprlandCfg.enable [ ]
then [ pkgs.hyprland ] ++ (if hyprlandCfg.enable then [ pkgs.hyprland ] else [ ])
else []) ++ (
++ (if plasmaCfg.enable if
plasmaCfg.enable
# TODO: use the correct packages or config # TODO: use the correct packages or config
then [ pkgs.kdePackages.kde-gtk-config ] then
else []); [ pkgs.kdePackages.kde-gtk-config ]
else
[ ]
);
}; };
}; };
} }

View File

@ -1,12 +1,9 @@
{ {
config, config,
lib,
osConfig, osConfig,
pkgs, pkgs,
profile,
... ...
}: }:
with lib;
let let
cfg = osConfig.modules.zsh; cfg = osConfig.modules.zsh;
xdgCfg = config.xdg; xdgCfg = config.xdg;

View File

@ -2,7 +2,6 @@
config, config,
lib, lib,
osConfig, osConfig,
pkgs,
... ...
}: }:
with lib; with lib;

View File

@ -1,12 +1,8 @@
{ {
config,
lib, lib,
... ...
}: }:
with lib; with lib;
let
cfg = config.modules.displayManager;
in
{ {
options.modules.displayManager = { options.modules.displayManager = {
displayManager = mkOption { displayManager = mkOption {

View File

@ -1,12 +1,8 @@
{ {
config,
lib, lib,
... ...
}: }:
with lib; with lib;
let
cfg = config.modules.hyprland;
in
{ {
options.modules.hyprland = { options.modules.hyprland = {
enable = mkEnableOption { enable = mkEnableOption {

View File

@ -1,12 +1,8 @@
{ {
config,
lib, lib,
... ...
}: }:
with lib; with lib;
let
cfg = config.modules.pipewire;
in
{ {
options.modules.pipewire = { options.modules.pipewire = {
enable = mkEnableOption { enable = mkEnableOption {

View File

@ -1,12 +1,8 @@
{ {
config,
lib, lib,
... ...
}: }:
with lib; with lib;
let
cfg = config.modules.plasma;
in
{ {
options.modules.plasma = { options.modules.plasma = {
enable = mkEnableOption { enable = mkEnableOption {

View File

@ -22,11 +22,17 @@ in
}; };
}; };
config.assertions = [] config.assertions =
++ (if cfg.defaultShell == "zsh" [ ]
then [{ ++ (
if cfg.defaultShell == "zsh" then
[
{
assertion = zshCfg.enable; assertion = zshCfg.enable;
message = "You have selected zsh as the default shell, but you haven't enabled it in your configuration.\n\nPlease enable it by adding `modules.zsh.enable = true`."; message = "You have selected zsh as the default shell, but you haven't enabled it in your configuration.\n\nPlease enable it by adding `modules.zsh.enable = true`.";
}] }
else []); ]
else
[ ]
);
} }

View File

@ -1,12 +1,8 @@
{ {
config,
lib, lib,
... ...
}: }:
with lib; with lib;
let
cfg = config.system;
in
{ {
options.system = { options.system = {
locale = mkOption { locale = mkOption {

View File

@ -1,12 +1,8 @@
{ {
config,
lib, lib,
... ...
}: }:
with lib; with lib;
let
cfg = config.modules.zsh;
in
{ {
options.modules.zsh = { options.modules.zsh = {
enable = mkEnableOption { enable = mkEnableOption {

View File

@ -5,7 +5,9 @@
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05"; nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
}; };
outputs = { self, nixpkgs, ... }: let outputs =
{ nixpkgs, ... }:
let
system = "x86_64-linux"; system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system}.pkgs; pkgs = nixpkgs.legacyPackages.${system}.pkgs;
name = builtins.baseNameOf (builtins.toString ./.); name = builtins.baseNameOf (builtins.toString ./.);
@ -20,7 +22,8 @@
unixtools.column unixtools.column
]; ];
}; };
in { in
{
packages.${system}.default = shellApplication; packages.${system}.default = shellApplication;
devShells.${system}.default = pkgs.mkShell { devShells.${system}.default = pkgs.mkShell {

View File

@ -5,7 +5,9 @@
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05"; nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
}; };
outputs = { self, nixpkgs, ... }: let outputs =
{ nixpkgs, ... }:
let
pkgs = nixpkgs.legacyPackages.x86_64-linux.pkgs; pkgs = nixpkgs.legacyPackages.x86_64-linux.pkgs;
name = builtins.baseNameOf (builtins.toString ./.); name = builtins.baseNameOf (builtins.toString ./.);
shellApplication = pkgs.writeShellApplication { shellApplication = pkgs.writeShellApplication {
@ -19,7 +21,8 @@
unixtools.column unixtools.column
]; ];
}; };
in { in
{
packages.x86_64-linux.default = shellApplication; packages.x86_64-linux.default = shellApplication;
devShells.x86_64-linux.default = pkgs.mkShell { devShells.x86_64-linux.default = pkgs.mkShell {