Various fixes and change formatter to nixfmt-rfc-style #19

Merged
jalil merged 3 commits from various-fixes into main 2024-07-04 23:07:29 +02:00
28 changed files with 800 additions and 742 deletions
Showing only changes of commit 91284a73ca - Show all commits

View file

@ -1,41 +1,38 @@
{ { pkgs, lib }:
pkgs, let
lib,
}: let
# can be removed once https://github.com/rust-lang/mdBook/pull/2262 lands # can be removed once https://github.com/rust-lang/mdBook/pull/2262 lands
highlight = pkgs.fetchurl { highlight = pkgs.fetchurl {
url = "https://raw.githubusercontent.com/rust-lang/mdBook/7b9bd5049ce15ae5f301d5a40c50ce8359d9e9a8/src/theme/highlight.js"; url = "https://raw.githubusercontent.com/rust-lang/mdBook/7b9bd5049ce15ae5f301d5a40c50ce8359d9e9a8/src/theme/highlight.js";
hash = "sha256-pLP73zlmGkbC/zV6bwnB6ijRf9gVkj5/VYMGLhiQ1/Q="; hash = "sha256-pLP73zlmGkbC/zV6bwnB6ijRf9gVkj5/VYMGLhiQ1/Q=";
}; };
filterVisible = toplevelOption: option: filterVisible =
option // {visible = option.visible && builtins.elemAt option.loc 0 == toplevelOption;}; toplevelOption: option:
option // { visible = option.visible && builtins.elemAt option.loc 0 == toplevelOption; };
home-eval = lib.evalModules { home-eval = lib.evalModules {
modules = [../home/options.nix]; modules = [ ../home/options.nix ];
specialArgs = { specialArgs = {
inherit pkgs; inherit pkgs;
}; };
}; };
nvim-eval = lib.evalModules {modules = [../nvim/options.nix];}; nvim-eval = lib.evalModules { modules = [ ../nvim/options.nix ]; };
nixos-eval = lib.evalModules {modules = [../system/options.nix];}; nixos-eval = lib.evalModules { modules = [ ../system/options.nix ]; };
home-markdown = home-markdown =
(pkgs.nixosOptionsDoc { (pkgs.nixosOptionsDoc {
inherit (home-eval) options; inherit (home-eval) options;
transformOptions = filterVisible "jhome"; transformOptions = filterVisible "jhome";
}) }).optionsCommonMark;
.optionsCommonMark;
nvim-markdown = nvim-markdown =
(pkgs.nixosOptionsDoc { (pkgs.nixosOptionsDoc {
inherit (nvim-eval) options; inherit (nvim-eval) options;
transformOptions = filterVisible "jhome"; transformOptions = filterVisible "jhome";
}) }).optionsCommonMark;
.optionsCommonMark;
nixos-markdown = nixos-markdown =
(pkgs.nixosOptionsDoc { (pkgs.nixosOptionsDoc {
inherit (nixos-eval) options; inherit (nixos-eval) options;
transformOptions = filterVisible "jconfig"; transformOptions = filterVisible "jconfig";
}) }).optionsCommonMark;
.optionsCommonMark; in
in { {
inherit nixos-markdown nvim-markdown home-markdown; inherit nixos-markdown nvim-markdown home-markdown;
docs = pkgs.stdenvNoCC.mkDerivation { docs = pkgs.stdenvNoCC.mkDerivation {
name = "nixos-configuration-book"; name = "nixos-configuration-book";
@ -57,7 +54,7 @@ in {
sed -f sed-cmds <${nixos-markdown} >> ./src/nixos-options.md sed -f sed-cmds <${nixos-markdown} >> ./src/nixos-options.md
''; '';
nativeBuildInputs = [pkgs.mdbook-toc]; nativeBuildInputs = [ pkgs.mdbook-toc ];
buildPhase = "${pkgs.mdbook}/bin/mdbook build --dest-dir $out"; buildPhase = "${pkgs.mdbook}/bin/mdbook build --dest-dir $out";
}; };
} }

View file

@ -63,7 +63,8 @@
}; };
# Flake outputs that other flakes can use # Flake outputs that other flakes can use
outputs = { outputs =
{
self, self,
nixpkgs, nixpkgs,
unstable, unstable,
@ -75,14 +76,16 @@
nixvim, nixvim,
lix-module, lix-module,
... ...
}: let }:
let
inherit (nixpkgs) lib; inherit (nixpkgs) lib;
# Helpers for producing system-specific outputs # Helpers for producing system-specific outputs
supportedSystems = [ supportedSystems = [
"x86_64-linux" "x86_64-linux"
"aarch64-linux" "aarch64-linux"
]; ];
forEachSupportedSystem = f: forEachSupportedSystem =
f:
nixpkgs.lib.genAttrs supportedSystems ( nixpkgs.lib.genAttrs supportedSystems (
system: system:
f { f {
@ -91,25 +94,26 @@
} }
); );
overlays = builtins.attrValues self.overlays; overlays = builtins.attrValues self.overlays;
in { in
checks = forEachSupportedSystem (
{ {
pkgs, checks = forEachSupportedSystem (
system, { pkgs, system }:
}: let let
src = builtins.path { src = builtins.path {
path = ./.; path = ./.;
name = "configuration.nix"; name = "configuration.nix";
}; };
runCmdInSrc = name: cmd: runCmdInSrc =
pkgs.runCommandNoCC name {} '' name: cmd:
pkgs.runCommandNoCC name { } ''
cd ${src} cd ${src}
${cmd} ${cmd}
mkdir $out mkdir $out
''; '';
in { in
{
nvim = nixvim.lib.${system}.check.mkTestDerivationFromNixvimModule { nvim = nixvim.lib.${system}.check.mkTestDerivationFromNixvimModule {
pkgs = import nixpkgs {inherit system overlays;}; pkgs = import nixpkgs { inherit system overlays; };
module = ./nvim/standalone.nix; module = ./nvim/standalone.nix;
}; };
fmt = runCmdInSrc "fmt-src" "${lib.getExe self.formatter.${system}} --check ."; fmt = runCmdInSrc "fmt-src" "${lib.getExe self.formatter.${system}} --check .";
@ -119,12 +123,9 @@
); );
packages = forEachSupportedSystem ( packages = forEachSupportedSystem (
{ pkgs, system }:
{ {
pkgs, inherit (import ./docs { inherit pkgs lib; })
system,
}: {
inherit
(import ./docs {inherit pkgs lib;})
docs docs
nixos-markdown nixos-markdown
nvim-markdown nvim-markdown
@ -132,7 +133,7 @@
; ;
# Nvim standalone module # Nvim standalone module
nvim = nixvim.legacyPackages.${system}.makeNixvimWithModule { nvim = nixvim.legacyPackages.${system}.makeNixvimWithModule {
pkgs = import nixpkgs {inherit system overlays;}; pkgs = import nixpkgs { inherit system overlays; };
module = ./nvim/standalone.nix; module = ./nvim/standalone.nix;
}; };
} }
@ -143,16 +144,18 @@
nixvim = nixvim.overlays.default; nixvim = nixvim.overlays.default;
jpassmenu = jpassmenu.overlays.default; jpassmenu = jpassmenu.overlays.default;
audiomenu = audiomenu.overlays.default; audiomenu = audiomenu.overlays.default;
unstable = final: prev: let unstable =
final: prev:
let
unstablePkgs = unstable.legacyPackages.${prev.system}; unstablePkgs = unstable.legacyPackages.${prev.system};
in { in
{
# Get unstable packages # Get unstable packages
unstable = unstablePkgs; unstable = unstablePkgs;
# Update vim plugins with the versions from unstable # Update vim plugins with the versions from unstable
vimPlugins = prev.vimPlugins // unstablePkgs.vimPlugins; vimPlugins = prev.vimPlugins // unstablePkgs.vimPlugins;
# Get specific packages from unstable # Get specific packages from unstable
inherit inherit (unstablePkgs)
(unstablePkgs)
gitoxide gitoxide
jujutsu jujutsu
wezterm wezterm
@ -162,13 +165,14 @@
}; };
# Nix files formatter (run `nix fmt`) # Nix files formatter (run `nix fmt`)
formatter = forEachSupportedSystem ({pkgs, ...}: pkgs.alejandra); formatter = forEachSupportedSystem ({ pkgs, ... }: pkgs.nixfmt-rfc-style);
# Example vm configuration # Example vm configuration
nixosConfigurations.vm = let nixosConfigurations.vm =
let
system = "x86_64-linux"; system = "x86_64-linux";
config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) ["steam-original"]; config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "steam-original" ];
pkgs = import nixpkgs {inherit system overlays config;}; pkgs = import nixpkgs { inherit system overlays config; };
in in
lib.nixosSystem { lib.nixosSystem {
inherit system pkgs; inherit system pkgs;
@ -206,24 +210,23 @@
]; ];
}; };
nixosModules = let nixosModules =
let
nvim-config.imports = [ nvim-config.imports = [
nixvim.homeManagerModules.nixvim nixvim.homeManagerModules.nixvim
./nvim ./nvim
]; ];
homeManagerModuleSandalone = import ./home {inherit nvim-config stylix;}; homeManagerModuleSandalone = import ./home { inherit nvim-config stylix; };
homeManagerModuleNixOS = import ./home {inherit nvim-config;}; homeManagerModuleNixOS = import ./home { inherit nvim-config; };
nixosModule = { nixosModule = {
imports = imports = [
[ (import ./system { inherit stylix; })
(import ./system {inherit stylix;})
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
] ] ++ nixpkgs.lib.optional (lix-module != null) lix-module.nixosModules.default;
++ nixpkgs.lib.optional (lix-module != null) lix-module.nixosModules.default;
home-manager = { home-manager = {
useGlobalPkgs = true; useGlobalPkgs = true;
useUserPackages = true; useUserPackages = true;
sharedModules = [homeManagerModuleNixOS]; sharedModules = [ homeManagerModuleNixOS ];
}; };
# Pin nixpkgs # Pin nixpkgs
nix.registry.nixpkgs.flake = nixpkgs; nix.registry.nixpkgs.flake = nixpkgs;
@ -238,9 +241,9 @@
mkMachine = hostname: { mkMachine = hostname: {
imports = [ imports = [
nixosModule nixosModule
(import (./machines + "/${hostname}") {inherit nixos-hardware;}) (import (./machines + "/${hostname}") { inherit nixos-hardware; })
]; ];
home-manager.sharedModules = [{jhome.hostName = hostname;}]; home-manager.sharedModules = [ { jhome.hostName = hostname; } ];
}; };
machineModules = lib.genAttrs machines mkMachine; machineModules = lib.genAttrs machines mkMachine;
in in
@ -251,10 +254,8 @@
// machineModules; // machineModules;
devShells = forEachSupportedSystem ( devShells = forEachSupportedSystem (
{ pkgs, system }:
{ {
pkgs,
system,
}: {
default = pkgs.mkShell { default = pkgs.mkShell {
buildInputs = [ buildInputs = [
pkgs.just pkgs.just

View file

@ -1,15 +1,18 @@
{ {
nvim-config, nvim-config,
stylix ? null, stylix ? null,
}: { }:
{
config, config,
pkgs, pkgs,
lib, lib,
... ...
}: let }:
let
cfg = config.jhome; cfg = config.jhome;
devcfg = cfg.dev; devcfg = cfg.dev;
in { in
{
imports = imports =
[ [
nvim-config nvim-config
@ -19,11 +22,11 @@ in {
] ]
++ lib.optionals (stylix != null) [ ++ lib.optionals (stylix != null) [
stylix.homeManagerModules.stylix stylix.homeManagerModules.stylix
{stylix.image = cfg.sway.background;} { stylix.image = cfg.sway.background; }
]; ];
config = lib.mkMerge [ config = lib.mkMerge [
(lib.mkIf (cfg.enable && cfg.styling.enable) {stylix.enable = true;}) (lib.mkIf (cfg.enable && cfg.styling.enable) { stylix.enable = true; })
(lib.mkIf cfg.enable { (lib.mkIf cfg.enable {
programs = { programs = {
# Better cat (bat) # Better cat (bat)
@ -81,10 +84,7 @@ in {
gpg-agent = { gpg-agent = {
enable = true; enable = true;
maxCacheTtl = 86400; maxCacheTtl = 86400;
pinentryPackage = pinentryPackage = if config.jhome.gui.enable then pkgs.pinentry-qt else pkgs.pinentry-curses;
if config.jhome.gui.enable
then pkgs.pinentry-qt
else pkgs.pinentry-curses;
extraConfig = "allow-preset-passphrase"; extraConfig = "allow-preset-passphrase";
}; };
# Spotifyd # Spotifyd
@ -189,7 +189,7 @@ in {
}; };
}) })
(lib.mkIf (cfg.enable && devcfg.enable && devcfg.rust.enable) { (lib.mkIf (cfg.enable && devcfg.enable && devcfg.rust.enable) {
home.packages = [pkgs.rustup] ++ devcfg.rust.extraPackages; home.packages = [ pkgs.rustup ] ++ devcfg.rust.extraPackages;
# Background code checker (for Rust) # Background code checker (for Rust)
programs.bacon = { programs.bacon = {
enable = true; enable = true;

View file

@ -4,17 +4,12 @@
pkgs, pkgs,
osConfig ? null, osConfig ? null,
... ...
}: let }:
let
inherit (config) jhome; inherit (config) jhome;
flatpakEnabled = flatpakEnabled = if osConfig != null then osConfig.services.flatpak.enable else false;
if osConfig != null
then osConfig.services.flatpak.enable
else false;
osSway = osConfig == null && !osConfig.programs.sway.enable; osSway = osConfig == null && !osConfig.programs.sway.enable;
swayPkg = swayPkg = if osSway then pkgs.sway else null;
if osSway
then pkgs.sway
else null;
cfg = jhome.gui; cfg = jhome.gui;
cursor = { cursor = {
package = pkgs.nordzy-cursor-theme; package = pkgs.nordzy-cursor-theme;
@ -24,9 +19,11 @@
name = "Papirus-Dark"; name = "Papirus-Dark";
package = pkgs.papirus-icon-theme; package = pkgs.papirus-icon-theme;
}; };
in { in
{
config = lib.mkIf (jhome.enable && cfg.enable) { config = lib.mkIf (jhome.enable && cfg.enable) {
home.packages = with pkgs; home.packages =
with pkgs;
[ [
webcord webcord
ferdium ferdium
@ -36,16 +33,25 @@ in {
wl-clipboard wl-clipboard
# Extra fonts # Extra fonts
noto-fonts-cjk # Chinese, Japanese and Korean characters noto-fonts-cjk # Chinese, Japanese and Korean characters
(pkgs.nerdfonts.override {fonts = ["NerdFontsSymbolsOnly"];}) (pkgs.nerdfonts.override { fonts = [ "NerdFontsSymbolsOnly" ]; })
] ]
++ lib.optional flatpakEnabled flatpak; ++ lib.optional flatpakEnabled flatpak;
fonts.fontconfig = { fonts.fontconfig = {
enable = true; enable = true;
defaultFonts = lib.mkIf config.jhome.styling.enable { defaultFonts = lib.mkIf config.jhome.styling.enable {
emoji = ["Noto Color Emoji"]; emoji = [ "Noto Color Emoji" ];
monospace = ["JetBrains Mono" "Symbols Nerd Font"]; monospace = [
serif = ["Noto Serif" "Symbols Nerd Font"]; "JetBrains Mono"
sansSerif = ["Noto Sans" "Symbols Nerd Font"]; "Symbols Nerd Font"
];
serif = [
"Noto Serif"
"Symbols Nerd Font"
];
sansSerif = [
"Noto Sans"
"Symbols Nerd Font"
];
}; };
}; };
# Browser # Browser
@ -63,13 +69,15 @@ in {
# Video player # Video player
mpv = { mpv = {
enable = true; enable = true;
scripts = builtins.attrValues {inherit (pkgs.mpvScripts) uosc thumbfast;}; scripts = builtins.attrValues { inherit (pkgs.mpvScripts) uosc thumbfast; };
}; };
# Status bar # Status bar
waybar = { waybar = {
enable = true; enable = true;
systemd.enable = true; systemd.enable = true;
settings = lib.mkIf config.jhome.styling.enable (import ./waybar-settings.nix {inherit config lib;}); settings = lib.mkIf config.jhome.styling.enable (
import ./waybar-settings.nix { inherit config lib; }
);
style = lib.optionalString config.jhome.styling.enable '' style = lib.optionalString config.jhome.styling.enable ''
.modules-left #workspaces button { .modules-left #workspaces button {
border-bottom: 3px solid @base01; border-bottom: 3px solid @base01;
@ -130,15 +138,17 @@ in {
wayland.windowManager.sway = { wayland.windowManager.sway = {
inherit (cfg.sway) enable; inherit (cfg.sway) enable;
package = swayPkg; # no sway package if it comes from the OS package = swayPkg; # no sway package if it comes from the OS
config = import ./sway-config.nix {inherit config pkgs;}; config = import ./sway-config.nix { inherit config pkgs; };
}; };
# Set cursor style # Set cursor style
stylix = lib.mkIf config.jhome.styling.enable {inherit cursor;}; stylix = lib.mkIf config.jhome.styling.enable { inherit cursor; };
home.pointerCursor = lib.mkIf config.jhome.styling.enable (lib.mkDefault { home.pointerCursor = lib.mkIf config.jhome.styling.enable (
lib.mkDefault {
gtk.enable = true; gtk.enable = true;
inherit (cursor) name package; inherit (cursor) name package;
}); }
);
# Set Gtk theme # Set Gtk theme
gtk = lib.mkIf config.jhome.styling.enable { gtk = lib.mkIf config.jhome.styling.enable {
enable = true; enable = true;

View file

@ -1,7 +1,5 @@
{ { pkgs, config }:
pkgs, let
config,
}: let
cfg = config.jhome.gui.sway; cfg = config.jhome.gui.sway;
passmenu = "${pkgs.jpassmenu}/bin/jpassmenu"; passmenu = "${pkgs.jpassmenu}/bin/jpassmenu";
selectAudio = "${pkgs.audiomenu}/bin/audiomenu --menu 'fuzzel --dmenu'"; selectAudio = "${pkgs.audiomenu}/bin/audiomenu --menu 'fuzzel --dmenu'";
@ -33,8 +31,8 @@
]; ];
joinKeys = builtins.concatStringsSep "+"; joinKeys = builtins.concatStringsSep "+";
# Generate a keybind from a modifier prefix and a key # Generate a keybind from a modifier prefix and a key
keycombo = prefix: key: joinKeys (prefix ++ [key]); keycombo = prefix: key: joinKeys (prefix ++ [ key ]);
modKeybind = keycombo [mod]; modKeybind = keycombo [ mod ];
modCtrlKeybind = keycombo [ modCtrlKeybind = keycombo [
mod mod
"Ctrl" "Ctrl"
@ -53,10 +51,13 @@
dir2resize.right = "resize grow width"; dir2resize.right = "resize grow width";
dir2resize.left = "resize shrink width"; dir2resize.left = "resize shrink width";
# Bind a key combo to an action # Bind a key combo to an action
genKeybind = prefix: action: key: {"${prefix key}" = "${action key}";}; genKeybind = prefix: action: key: { "${prefix key}" = "${action key}"; };
genKey = prefix: action: genKeybind ({key, ...}: prefix key) ({direction, ...}: action direction); genKey =
genArrow = prefix: action: genKeybind ({arrow, ...}: prefix arrow) ({direction, ...}: action direction); prefix: action: genKeybind ({ key, ... }: prefix key) ({ direction, ... }: action direction);
genArrowAndKey = prefix: action: key: genArrow =
prefix: action: genKeybind ({ arrow, ... }: prefix arrow) ({ direction, ... }: action direction);
genArrowAndKey =
prefix: action: key:
(genKey prefix action key) // (genArrow prefix action key); (genKey prefix action key) // (genArrow prefix action key);
# Move window # Move window
moveWindowKeybinds = map (genArrowAndKey modShiftKeybind (dir: "move ${dir}")) dirs; moveWindowKeybinds = map (genArrowAndKey modShiftKeybind (dir: "move ${dir}")) dirs;
@ -65,25 +66,19 @@
# Resize window # Resize window
resizeWindowKeybinds = map (genArrowAndKey modCtrlKeybind (dir: dir2resize.${dir})) dirs; resizeWindowKeybinds = map (genArrowAndKey modCtrlKeybind (dir: dir2resize.${dir})) dirs;
# Move container to workspace # Move container to workspace
moveWorkspaceKeybindings = moveWorkspaceKeybindings = map (genKeybind modShiftKeybind (
map (genKeybind modShiftKeybind (
number: "move container to workspace number ${number}" number: "move container to workspace number ${number}"
)) )) workspaces;
workspaces;
# Focus workspace # Focus workspace
focusWorkspaceKeybindings = focusWorkspaceKeybindings = map (genKeybind modKeybind (
map (genKeybind modKeybind (
number: "workspace number ${number}" number: "workspace number ${number}"
)) )) workspaces;
workspaces;
# Move container to Workspace and focus on it # Move container to Workspace and focus on it
moveFocusWorkspaceKeybindings = moveFocusWorkspaceKeybindings = map (genKeybind modCtrlShiftKeybind (
map (genKeybind modCtrlShiftKeybind (
number: "move container to workspace number ${number}; workspace number ${number}" number: "move container to workspace number ${number}; workspace number ${number}"
)) )) workspaces;
workspaces;
in in
builtins.foldl' (l: r: l // r) builtins.foldl' (l: r: l // r)
{ {
"${mod}+Return" = "exec ${swayconf.terminal}"; "${mod}+Return" = "exec ${swayconf.terminal}";
"${mod}+D" = "exec ${swayconf.menu}"; "${mod}+D" = "exec ${swayconf.menu}";

View file

@ -1,16 +1,15 @@
{ { config, pkgs }:
config, let
pkgs,
}: let
cfg = config.jhome.gui.sway; cfg = config.jhome.gui.sway;
modifier = "Mod4"; modifier = "Mod4";
inherit (config.jhome.gui) terminal; inherit (config.jhome.gui) terminal;
termCmd = termCmd =
if terminal == "wezterm" if terminal == "wezterm" then
then "wezterm start" "wezterm start"
else if terminal == "alacritty" else if terminal == "alacritty" then
then "alacritty -e" "alacritty -e"
else builtins.abort "no command configured for ${terminal}"; else
builtins.abort "no command configured for ${terminal}";
menu = "${pkgs.fuzzel}/bin/fuzzel --terminal '${termCmd}'"; menu = "${pkgs.fuzzel}/bin/fuzzel --terminal '${termCmd}'";
# currently, there is some friction between sway and gtk: # currently, there is some friction between sway and gtk:
# https://github.com/swaywm/sway/wiki/GTK-3-settings-on-Wayland # https://github.com/swaywm/sway/wiki/GTK-3-settings-on-Wayland
@ -18,7 +17,8 @@
# for gsettings to work, we need to tell it where the schemas are # for gsettings to work, we need to tell it where the schemas are
# using the XDG_DATA_DIR environment variable # using the XDG_DATA_DIR environment variable
# run at the end of sway config # run at the end of sway config
configure-gtk = let configure-gtk =
let
schema = pkgs.gsettings-desktop-schemas; schema = pkgs.gsettings-desktop-schemas;
datadir = "${schema}/share/gsettings-schemas/${schema.name}"; datadir = "${schema}/share/gsettings-schemas/${schema.name}";
in in
@ -38,16 +38,17 @@
${pkgs.glib}/bin/gsettings set "$gnome_schema" font-name "$font_name" ${pkgs.glib}/bin/gsettings set "$gnome_schema" font-name "$font_name"
${pkgs.glib}/bin/gsettings set "$gnome_schema" color-scheme prefer-dark ${pkgs.glib}/bin/gsettings set "$gnome_schema" color-scheme prefer-dark
''; '';
cmdOnce = command: {inherit command;}; cmdOnce = command: { inherit command; };
cmdAlways = command: { cmdAlways = command: {
inherit command; inherit command;
always = true; always = true;
}; };
in { in
{
inherit modifier terminal menu; inherit modifier terminal menu;
keybindings = import ./keybindings.nix {inherit config pkgs;}; keybindings = import ./keybindings.nix { inherit config pkgs; };
# Appearance # Appearance
bars = []; # Waybar is started as a systemd service bars = [ ]; # Waybar is started as a systemd service
gaps = { gaps = {
smartGaps = true; smartGaps = true;
smartBorders = "on"; smartBorders = "on";
@ -72,12 +73,9 @@ in {
} }
]; ];
# Startup scripts # Startup scripts
startup = startup = [
[
(cmdAlways "${configure-gtk}/bin/configure-gtk") (cmdAlways "${configure-gtk}/bin/configure-gtk")
] ] ++ (builtins.map cmdAlways cfg.exec.always) ++ (builtins.map cmdOnce cfg.exec.once);
++ (builtins.map cmdAlways cfg.exec.always)
++ (builtins.map cmdOnce cfg.exec.once);
# Keyboard configuration # Keyboard configuration
input."type:keyboard" = { input."type:keyboard" = {
repeat_delay = "300"; repeat_delay = "300";

View file

@ -1,38 +1,34 @@
{ { config, lib }:
config, let
lib,
}: let
cfg = config.jhome.gui; cfg = config.jhome.gui;
in { in
{
mainBar = { mainBar = {
layer = "top"; layer = "top";
position = "top"; position = "top";
margin = "2 2 2 2"; margin = "2 2 2 2";
# Choose the order of the modules # Choose the order of the modules
modules-left = ["sway/workspaces"]; modules-left = [ "sway/workspaces" ];
modules-center = ["clock"]; modules-center = [ "clock" ];
modules-right = modules-right = [
[
"pulseaudio" "pulseaudio"
"backlight" "backlight"
"battery" "battery"
"sway/language" "sway/language"
"memory" "memory"
] ] ++ lib.optional (cfg.tempInfo != null) "temperature" ++ [ "tray" ];
++ lib.optional (cfg.tempInfo != null) "temperature"
++ ["tray"];
"sway/workspaces" = { "sway/workspaces" = {
disable-scroll = true; disable-scroll = true;
persistent-workspaces = { persistent-workspaces = {
"1" = []; "1" = [ ];
"2" = []; "2" = [ ];
"3" = []; "3" = [ ];
"4" = []; "4" = [ ];
"5" = []; "5" = [ ];
"6" = []; "6" = [ ];
"7" = []; "7" = [ ];
"8" = []; "8" = [ ];
"9" = []; "9" = [ ];
}; };
}; };
"sway/language" = { "sway/language" = {
@ -64,7 +60,11 @@ in {
phone = "󰘂"; phone = "󰘂";
portable = ""; portable = "";
car = ""; car = "";
default = ["󰕿" "󰖀" "󰕾"]; default = [
"󰕿"
"󰖀"
"󰕾"
];
}; };
on-click = "pavucontrol"; on-click = "pavucontrol";
min-length = 13; min-length = 13;
@ -73,13 +73,27 @@ in {
inherit (cfg.tempInfo) hwmon-path; inherit (cfg.tempInfo) hwmon-path;
critical-threshold = 80; critical-threshold = 80;
format = "{temperatureC}°C {icon}"; format = "{temperatureC}°C {icon}";
format-icons = ["" "" "" "" ""]; format-icons = [
""
""
""
""
""
];
tooltip = false; tooltip = false;
}; };
backlight = { backlight = {
device = "intel_backlight"; device = "intel_backlight";
format = "{percent}% {icon}"; format = "{percent}% {icon}";
format-icons = ["󰃚" "󰃛" "󰃜" "󰃝" "󰃞" "󰃟" "󰃠"]; format-icons = [
"󰃚"
"󰃛"
"󰃜"
"󰃝"
"󰃞"
"󰃟"
"󰃠"
];
min-length = 7; min-length = 7;
}; };
battery = { battery = {
@ -89,7 +103,18 @@ in {
format-charging = "{capacity}% 󰂄"; format-charging = "{capacity}% 󰂄";
format-plugged = "{capacity}% 󰚥"; format-plugged = "{capacity}% 󰚥";
format-alt = "{time} {icon}"; format-alt = "{time} {icon}";
format-icons = ["󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹"]; format-icons = [
"󰁺"
"󰁻"
"󰁼"
"󰁽"
"󰁾"
"󰁿"
"󰂀"
"󰂁"
"󰂂"
"󰁹"
];
}; };
tray = { tray = {
icon-size = 16; icon-size = 16;

View file

@ -1,28 +1,22 @@
{ { lib, pkgs, ... }@attrs:
lib, let
pkgs,
...
} @ attrs: let
osConfig = attrs.osConfig or null; osConfig = attrs.osConfig or null;
inherit (lib) types; inherit (lib) types;
fromOs = let fromOs =
get = path: set: let
if path == [] get =
then set path: set:
else get (builtins.tail path) (builtins.getAttr (builtins.head path) set); if path == [ ] then set else get (builtins.tail path) (builtins.getAttr (builtins.head path) set);
in in
path: default: path: default: if osConfig == null then default else get path osConfig;
if osConfig == null fromConfig = path: default: fromOs ([ "jconfig" ] ++ path) default;
then default
else get path osConfig;
fromConfig = path: default: fromOs (["jconfig"] ++ path) default;
mkExtraPackagesOption = name: defaultPkgsPath: let mkExtraPackagesOption =
text = name: defaultPkgsPath:
lib.strings.concatMapStringsSep " " ( let
text = lib.strings.concatMapStringsSep " " (
pkgPath: "pkgs." + (lib.strings.concatStringsSep "." pkgPath) pkgPath: "pkgs." + (lib.strings.concatStringsSep "." pkgPath)
) ) defaultPkgsPath;
defaultPkgsPath;
defaultText = lib.literalExpression "[ ${text} ]"; defaultText = lib.literalExpression "[ ${text} ]";
default = builtins.map (pkgPath: lib.attrsets.getAttrFromPath pkgPath pkgs) defaultPkgsPath; default = builtins.map (pkgPath: lib.attrsets.getAttrFromPath pkgPath pkgs) defaultPkgsPath;
in in
@ -30,7 +24,7 @@
description = "Extra ${name} Packages."; description = "Extra ${name} Packages.";
type = types.listOf types.package; type = types.listOf types.package;
inherit default defaultText; inherit default defaultText;
example = []; example = [ ];
}; };
identity.options = { identity.options = {
@ -62,12 +56,12 @@
enable = lib.mkEnableOption "Jalil's default user configuration"; enable = lib.mkEnableOption "Jalil's default user configuration";
gpg = lib.mkOption { gpg = lib.mkOption {
description = "GnuPG Configuration."; description = "GnuPG Configuration.";
default = {}; default = { };
type = types.submodule { type = types.submodule {
options.unlockKeys = lib.mkOption { options.unlockKeys = lib.mkOption {
description = "Keygrips of keys to unlock through `pam-gnupg` when logging in."; description = "Keygrips of keys to unlock through `pam-gnupg` when logging in.";
default = []; default = [ ];
example = ["6F4ABB77A88E922406BCE6627AFEEE2363914B76"]; example = [ "6F4ABB77A88E922406BCE6627AFEEE2363914B76" ];
type = types.listOf types.str; type = types.listOf types.str;
}; };
}; };
@ -85,14 +79,27 @@
}; };
sway.options = { sway.options = {
enable = lib.mkEnableOption "sway" // {default = fromConfig ["gui" "sway"] true;}; enable = lib.mkEnableOption "sway" // {
default = fromConfig [
"gui"
"sway"
] true;
};
background = lib.mkOption { background = lib.mkOption {
description = "The wallpaper to use."; description = "The wallpaper to use.";
type = types.path; type = types.path;
default = fromConfig ["styling" "wallpaper"] (builtins.fetchurl { default =
fromConfig
[
"styling"
"wallpaper"
]
(
builtins.fetchurl {
url = "https://raw.githubusercontent.com/lunik1/nixos-logo-gruvbox-wallpaper/d4937c424fad79c1136a904599ba689fcf8d0fad/png/gruvbox-dark-rainbow.png"; url = "https://raw.githubusercontent.com/lunik1/nixos-logo-gruvbox-wallpaper/d4937c424fad79c1136a904599ba689fcf8d0fad/png/gruvbox-dark-rainbow.png";
sha256 = "036gqhbf6s5ddgvfbgn6iqbzgizssyf7820m5815b2gd748jw8zc"; sha256 = "036gqhbf6s5ddgvfbgn6iqbzgizssyf7820m5815b2gd748jw8zc";
}); }
);
}; };
autostart = lib.mkOption { autostart = lib.mkOption {
description = '' description = ''
@ -109,20 +116,20 @@
}; };
exec = lib.mkOption { exec = lib.mkOption {
description = "Run commands when starting sway."; description = "Run commands when starting sway.";
default = {}; default = { };
type = types.submodule { type = types.submodule {
options = { options = {
once = lib.mkOption { once = lib.mkOption {
description = "Programs to start only once (`exec`)."; description = "Programs to start only once (`exec`).";
type = types.listOf types.str; type = types.listOf types.str;
default = []; default = [ ];
example = ["signal-desktop --start-in-tray"]; example = [ "signal-desktop --start-in-tray" ];
}; };
always = lib.mkOption { always = lib.mkOption {
description = "Programs to start whenever the config is sourced (`exec_always`)."; description = "Programs to start whenever the config is sourced (`exec_always`).";
type = types.listOf types.str; type = types.listOf types.str;
default = []; default = [ ];
example = ["signal-desktop --start-in-tray"]; example = [ "signal-desktop --start-in-tray" ];
}; };
}; };
}; };
@ -130,7 +137,12 @@
}; };
gui.options = { gui.options = {
enable = lib.mkEnableOption "GUI applications" // {default = fromConfig ["gui" "enable"] false;}; enable = lib.mkEnableOption "GUI applications" // {
default = fromConfig [
"gui"
"enable"
] false;
};
tempInfo = lib.mkOption { tempInfo = lib.mkOption {
description = "Temperature info to display in the statusbar."; description = "Temperature info to display in the statusbar.";
default = null; default = null;
@ -138,7 +150,7 @@
}; };
sway = lib.mkOption { sway = lib.mkOption {
description = "Sway window manager configuration."; description = "Sway window manager configuration.";
default = {}; default = { };
type = types.submodule sway; type = types.submodule sway;
}; };
terminal = lib.mkOption { terminal = lib.mkOption {
@ -151,48 +163,57 @@
]; ];
}; };
}; };
in { in
{
options.jhome = lib.mkOption { options.jhome = lib.mkOption {
description = "Jalil's default home-manager configuration."; description = "Jalil's default home-manager configuration.";
default = {}; default = { };
type = types.submodule { type = types.submodule {
options = { options = {
enable = lib.mkEnableOption "jalil's home defaults"; enable = lib.mkEnableOption "jalil's home defaults";
hostName = lib.mkOption { hostName = lib.mkOption {
description = "The hostname of this system."; description = "The hostname of this system.";
type = types.str; type = types.str;
default = fromOs ["networking" "hostName"] "nixos"; default = fromOs [
"networking"
"hostName"
] "nixos";
example = "my pc"; example = "my pc";
}; };
dev = lib.mkOption { dev = lib.mkOption {
description = "Setup development environment for programming languages."; description = "Setup development environment for programming languages.";
default = {}; default = { };
type = types.submodule { type = types.submodule {
options = { options = {
enable = lib.mkEnableOption "development settings" // {default = fromConfig ["dev" "enable"] false;}; enable = lib.mkEnableOption "development settings" // {
default = fromConfig [
"dev"
"enable"
] false;
};
neovimAsManPager = lib.mkEnableOption "neovim as the man pager"; neovimAsManPager = lib.mkEnableOption "neovim as the man pager";
extraPackages = mkExtraPackagesOption "dev" [ extraPackages = mkExtraPackagesOption "dev" [
["jq"] # json parser [ "jq" ] # json parser
["just"] # just a command runner [ "just" ] # just a command runner
["typos"] # low false positive rate typo checker [ "typos" ] # low false positive rate typo checker
["gcc"] # GNU Compiler Collection [ "gcc" ] # GNU Compiler Collection
["git-absorb"] # fixup! but automatic [ "git-absorb" ] # fixup! but automatic
["man-pages"] # gimme the man pages [ "man-pages" ] # gimme the man pages
["man-pages-posix"] # I said gimme the man pages!!! [ "man-pages-posix" ] # I said gimme the man pages!!!
]; ];
rust = lib.mkOption { rust = lib.mkOption {
description = "Jalil's default rust configuration."; description = "Jalil's default rust configuration.";
default = {}; default = { };
type = types.submodule { type = types.submodule {
options.enable = lib.mkEnableOption "rust development settings"; options.enable = lib.mkEnableOption "rust development settings";
options.extraPackages = mkExtraPackagesOption "Rust" [ options.extraPackages = mkExtraPackagesOption "Rust" [
["cargo-insta"] # snapshot testing [ "cargo-insta" ] # snapshot testing
["cargo-llvm-cov"] # code coverage [ "cargo-llvm-cov" ] # code coverage
["cargo-msrv"] # minimum supported version [ "cargo-msrv" ] # minimum supported version
["cargo-nextest"] # better testing harness [ "cargo-nextest" ] # better testing harness
["cargo-sort"] # sort deps and imports [ "cargo-sort" ] # sort deps and imports
["cargo-udeps"] # check for unused dependencies (requires nightly) [ "cargo-udeps" ] # check for unused dependencies (requires nightly)
["cargo-watch"] # watch for file changes and run commands [ "cargo-watch" ] # watch for file changes and run commands
]; ];
}; };
}; };
@ -206,15 +227,20 @@ in {
}; };
gui = lib.mkOption { gui = lib.mkOption {
description = "Jalil's default GUI configuration."; description = "Jalil's default GUI configuration.";
default = {}; default = { };
type = types.submodule gui; type = types.submodule gui;
}; };
styling = lib.mkOption { styling = lib.mkOption {
description = "My custom styling (uses stylix)"; description = "My custom styling (uses stylix)";
default = {}; default = { };
type = types.submodule { type = types.submodule {
options = { options = {
enable = lib.mkEnableOption "styling" // {default = fromConfig ["styling" "enable"] true;}; enable = lib.mkEnableOption "styling" // {
default = fromConfig [
"styling"
"enable"
] true;
};
}; };
}; };
}; };

View file

@ -1,8 +1,5 @@
{ { config, lib, ... }:
config, let
lib,
...
}: let
inherit (config) jhome; inherit (config) jhome;
inherit (cfg.defaultIdentity) signingKey; inherit (cfg.defaultIdentity) signingKey;
@ -10,8 +7,9 @@
hasConfig = jhome.enable && cfg != null; hasConfig = jhome.enable && cfg != null;
hasKey = signingKey != null; hasKey = signingKey != null;
gpgHome = config.programs.gpg.homedir; gpgHome = config.programs.gpg.homedir;
unlockKey = hasConfig && cfg.gpg.unlockKeys != []; unlockKey = hasConfig && cfg.gpg.unlockKeys != [ ];
in { in
{
config = lib.mkMerge [ config = lib.mkMerge [
(lib.mkIf hasConfig { (lib.mkIf hasConfig {
programs.git = { programs.git = {
@ -23,7 +21,7 @@ in {
}; };
}; };
programs.jujutsu.settings = { programs.jujutsu.settings = {
user = lib.mkIf (cfg.defaultIdentity != null) {inherit (cfg.defaultIdentity) name email;}; user = lib.mkIf (cfg.defaultIdentity != null) { inherit (cfg.defaultIdentity) name email; };
signing = lib.mkIf hasKey { signing = lib.mkIf hasKey {
sign-all = true; sign-all = true;
backend = "gpg"; backend = "gpg";

View file

@ -1,4 +1,5 @@
{nixos-hardware}: { { nixos-hardware }:
{
imports = [ imports = [
# Include the results of the hardware scan. # Include the results of the hardware scan.
./hardware-configuration.nix ./hardware-configuration.nix
@ -9,8 +10,8 @@
]; ];
fileSystems = { fileSystems = {
# Setup extra filesystem options # Setup extra filesystem options
"/".options = ["compress=zstd"]; "/".options = [ "compress=zstd" ];
"/home".options = ["compress=zstd"]; "/home".options = [ "compress=zstd" ];
"/nix".options = [ "/nix".options = [
"compress=zstd" "compress=zstd"
"noatime" "noatime"

View file

@ -6,8 +6,9 @@
lib, lib,
modulesPath, modulesPath,
... ...
}: { }:
imports = [(modulesPath + "/installer/scan/not-detected.nix")]; {
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot = { boot = {
initrd = { initrd = {
availableKernelModules = [ availableKernelModules = [
@ -16,22 +17,22 @@
"usb_storage" "usb_storage"
"sd_mod" "sd_mod"
]; ];
kernelModules = []; kernelModules = [ ];
}; };
kernelModules = ["kvm-intel"]; kernelModules = [ "kvm-intel" ];
extraModulePackages = []; extraModulePackages = [ ];
}; };
fileSystems = { fileSystems = {
"/" = { "/" = {
device = "/dev/disk/by-label/NIXROOT"; device = "/dev/disk/by-label/NIXROOT";
fsType = "btrfs"; fsType = "btrfs";
options = ["subvol=root"]; options = [ "subvol=root" ];
}; };
"/nix" = { "/nix" = {
device = "/dev/disk/by-label/NIXROOT"; device = "/dev/disk/by-label/NIXROOT";
fsType = "btrfs"; fsType = "btrfs";
options = ["subvol=nix"]; options = [ "subvol=nix" ];
}; };
"/home" = { "/home" = {
@ -45,7 +46,7 @@
}; };
}; };
swapDevices = [{device = "/dev/disk/by-label/NIXSWAP";}]; swapDevices = [ { device = "/dev/disk/by-label/NIXSWAP"; } ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's

View file

@ -1,7 +1,9 @@
# Edit this configuration file to define what should be installed on # Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page # your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help). # and in the NixOS manual (accessible by running nixos-help).
{nixos-hardware}: {pkgs, ...}: { { nixos-hardware }:
{ pkgs, ... }:
{
imports = [ imports = [
# Include the results of the hardware scan. # Include the results of the hardware scan.
./hardware-configuration.nix ./hardware-configuration.nix
@ -11,9 +13,9 @@
nixos-hardware.nixosModules.common-gpu-amd nixos-hardware.nixosModules.common-gpu-amd
]; ];
fileSystems = { fileSystems = {
"/".options = ["compress=zstd"]; "/".options = [ "compress=zstd" ];
"/steam".options = ["compress=zstd"]; "/steam".options = [ "compress=zstd" ];
"/home".options = ["compress=zstd"]; "/home".options = [ "compress=zstd" ];
"/nix".options = [ "/nix".options = [
"compress=zstd" "compress=zstd"
"noatime" "noatime"
@ -48,7 +50,7 @@
# }; # };
enable = true; enable = true;
startWhenNeeded = true; startWhenNeeded = true;
settings.AllowUsers = ["jalil"]; settings.AllowUsers = [ "jalil" ];
}; };
# Enable CUPS to print documents. # Enable CUPS to print documents.

View file

@ -6,8 +6,9 @@
lib, lib,
modulesPath, modulesPath,
... ...
}: { }:
imports = [(modulesPath + "/installer/scan/not-detected.nix")]; {
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot = { boot = {
initrd = { initrd = {
availableKernelModules = [ availableKernelModules = [
@ -18,17 +19,17 @@
"usb_storage" "usb_storage"
"sd_mod" "sd_mod"
]; ];
kernelModules = []; kernelModules = [ ];
}; };
kernelModules = ["kvm-amd"]; kernelModules = [ "kvm-amd" ];
extraModulePackages = []; extraModulePackages = [ ];
}; };
fileSystems = { fileSystems = {
"/" = { "/" = {
# device = "/dev/disk/by-label/NIXOSROOT"; # device = "/dev/disk/by-label/NIXOSROOT";
device = "/dev/disk/by-label/NIXOSHOME"; device = "/dev/disk/by-label/NIXOSHOME";
fsType = "btrfs"; fsType = "btrfs";
options = ["subvol=root"]; options = [ "subvol=root" ];
}; };
"/steam" = { "/steam" = {
@ -39,13 +40,13 @@
"/home" = { "/home" = {
device = "/dev/disk/by-label/NIXOSHOME"; device = "/dev/disk/by-label/NIXOSHOME";
fsType = "btrfs"; fsType = "btrfs";
options = ["subvol=home"]; options = [ "subvol=home" ];
}; };
"/nix" = { "/nix" = {
device = "/dev/disk/by-label/NIXOSROOT"; device = "/dev/disk/by-label/NIXOSROOT";
fsType = "btrfs"; fsType = "btrfs";
options = ["subvol=nix"]; options = [ "subvol=nix" ];
}; };
"/boot" = { "/boot" = {
@ -54,7 +55,7 @@
}; };
}; };
swapDevices = [{device = "/dev/disk/by-label/SWAP";}]; swapDevices = [ { device = "/dev/disk/by-label/SWAP"; } ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's

View file

@ -1,7 +1,9 @@
# Edit this configuration file to define what should be installed on # Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page, on # your system. Help is available in the configuration.nix(5) man page, on
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). # https://search.nixos.org/options and in the NixOS manual (`nixos-help`).
{nixos-hardware}: {pkgs, ...}: { { nixos-hardware }:
{ pkgs, ... }:
{
imports = [ imports = [
# Include the results of the hardware scan. # Include the results of the hardware scan.
./hardware-configuration.nix ./hardware-configuration.nix
@ -13,8 +15,8 @@
]; ];
fileSystems = { fileSystems = {
"/".options = ["compress=zstd"]; "/".options = [ "compress=zstd" ];
"/home".options = ["compress=zstd"]; "/home".options = [ "compress=zstd" ];
"/nix".options = [ "/nix".options = [
"compress=zstd" "compress=zstd"
"noatime" "noatime"
@ -22,7 +24,7 @@
}; };
boot = { boot = {
kernelPackages = pkgs.linuxPackages_latest; kernelPackages = pkgs.linuxPackages_latest;
kernelParams = ["amdgpu.dcdebugmask=0x10"]; kernelParams = [ "amdgpu.dcdebugmask=0x10" ];
loader = { loader = {
# Use the systemd-boot EFI boot loader. # Use the systemd-boot EFI boot loader.
timeout = 0; # Press Space to show the menu timeout = 0; # Press Space to show the menu

View file

@ -7,8 +7,9 @@
pkgs, pkgs,
modulesPath, modulesPath,
... ...
}: { }:
imports = [(modulesPath + "/installer/scan/not-detected.nix")]; {
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot = { boot = {
initrd = { initrd = {
availableKernelModules = [ availableKernelModules = [
@ -17,28 +18,28 @@
"usb_storage" "usb_storage"
"sd_mod" "sd_mod"
]; ];
kernelModules = []; kernelModules = [ ];
}; };
kernelModules = ["kvm-amd"]; kernelModules = [ "kvm-amd" ];
extraModulePackages = []; extraModulePackages = [ ];
}; };
fileSystems = { fileSystems = {
"/" = { "/" = {
device = "/dev/disk/by-uuid/efbda7f0-c286-4fb1-b780-d3128e4d1a3e"; device = "/dev/disk/by-uuid/efbda7f0-c286-4fb1-b780-d3128e4d1a3e";
fsType = "btrfs"; fsType = "btrfs";
options = ["subvol=root"]; options = [ "subvol=root" ];
}; };
"/home" = { "/home" = {
device = "/dev/disk/by-uuid/efbda7f0-c286-4fb1-b780-d3128e4d1a3e"; device = "/dev/disk/by-uuid/efbda7f0-c286-4fb1-b780-d3128e4d1a3e";
fsType = "btrfs"; fsType = "btrfs";
options = ["subvol=home"]; options = [ "subvol=home" ];
}; };
"/nix" = { "/nix" = {
device = "/dev/disk/by-uuid/efbda7f0-c286-4fb1-b780-d3128e4d1a3e"; device = "/dev/disk/by-uuid/efbda7f0-c286-4fb1-b780-d3128e4d1a3e";
fsType = "btrfs"; fsType = "btrfs";
options = ["subvol=nix"]; options = [ "subvol=nix" ];
}; };
"/boot" = { "/boot" = {
@ -47,7 +48,7 @@
}; };
}; };
swapDevices = []; swapDevices = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's

View file

@ -1,11 +1,13 @@
{helpers, ...}: let { helpers, ... }:
let
inherit (helpers) mkRaw; inherit (helpers) mkRaw;
in { in
{
config = { config = {
autoGroups = { autoGroups = {
"highlightOnYank" = {}; "highlightOnYank" = { };
"lspConfig" = {}; "lspConfig" = { };
"restoreCursorPosition" = {}; "restoreCursorPosition" = { };
}; };
autoCmd = [ autoCmd = [
{ {
@ -14,9 +16,7 @@ in {
pattern = "*"; pattern = "*";
callback = callback =
mkRaw mkRaw
/* # lua
lua
*/
'' ''
function() function()
vim.highlight.on_yank { vim.highlight.on_yank {
@ -34,9 +34,7 @@ in {
pattern = "*"; pattern = "*";
callback = callback =
mkRaw mkRaw
/* # lua
lua
*/
'' ''
function() function()
if vim.fn.line '\'"' > 0 and vim.fn.line '\'"' <= vim.fn.line '$' then if vim.fn.line '\'"' > 0 and vim.fn.line '\'"' <= vim.fn.line '$' then
@ -49,13 +47,12 @@ in {
group = "lspConfig"; group = "lspConfig";
event = "LspAttach"; event = "LspAttach";
pattern = "*"; pattern = "*";
callback = let callback =
let
opts = "noremap = true, buffer = bufnr"; opts = "noremap = true, buffer = bufnr";
in in
mkRaw mkRaw
/* # lua
lua
*/
'' ''
function(opts) function(opts)
local bufnr = opts.buf local bufnr = opts.buf

View file

@ -1,11 +1,9 @@
{ { lib, config, ... }:
lib, let
config,
...
}: let
cfg = config.jhome.nvim; cfg = config.jhome.nvim;
in { in
imports = [./options.nix]; {
imports = [ ./options.nix ];
config.programs.nixvim = lib.mkMerge [ config.programs.nixvim = lib.mkMerge [
./standalone.nix ./standalone.nix

View file

@ -1,4 +1,5 @@
{pkgs}: { { pkgs }:
vim-jjdescription = pkgs.callPackage ./vim-jjdescription.nix {}; {
nvim-silicon = pkgs.callPackage ./nvim-silicon.nix {}; vim-jjdescription = pkgs.callPackage ./vim-jjdescription.nix { };
nvim-silicon = pkgs.callPackage ./nvim-silicon.nix { };
} }

View file

@ -1,7 +1,4 @@
{ { vimUtils, fetchFromGitHub }:
vimUtils,
fetchFromGitHub,
}:
vimUtils.buildVimPlugin { vimUtils.buildVimPlugin {
name = "nvim-silicon"; name = "nvim-silicon";
src = fetchFromGitHub { src = fetchFromGitHub {

View file

@ -1,7 +1,4 @@
{ { vimUtils, fetchFromGitHub }:
vimUtils,
fetchFromGitHub,
}:
vimUtils.buildVimPlugin { vimUtils.buildVimPlugin {
name = "jjdescription"; name = "jjdescription";
src = fetchFromGitHub { src = fetchFromGitHub {

View file

@ -1,6 +1,8 @@
{helpers, ...}: let { helpers, ... }:
let
inherit (helpers) mkRaw; inherit (helpers) mkRaw;
in { in
{
config.keymaps = [ config.keymaps = [
# Quickfix # Quickfix
{ {

View file

@ -1,7 +1,6 @@
{lib, ...}: { { lib, ... }:
options.jhome.nvim.enable = {
lib.mkEnableOption "jalil's neovim configuration" options.jhome.nvim.enable = lib.mkEnableOption "jalil's neovim configuration" // {
// {
default = true; default = true;
example = false; example = false;
}; };

View file

@ -3,9 +3,11 @@
pkgs, pkgs,
helpers, helpers,
... ...
}: let }:
let
inherit (helpers) mkRaw; inherit (helpers) mkRaw;
in { in
{
config.plugins = { config.plugins = {
bacon = { bacon = {
enable = true; enable = true;
@ -17,38 +19,32 @@ in {
"/" = { "/" = {
mapping = mapping =
mkRaw mkRaw
/* # lua
lua
*/
'' ''
cmp.mapping.preset.cmdline() cmp.mapping.preset.cmdline()
''; '';
sources = [ sources = [
{name = "rg";} { name = "rg"; }
{name = "buffer";} { name = "buffer"; }
]; ];
}; };
":" = { ":" = {
mapping = mapping =
mkRaw mkRaw
/* # lua
lua
*/
'' ''
cmp.mapping.preset.cmdline() cmp.mapping.preset.cmdline()
''; '';
sources = [ sources = [
{name = "path";} { name = "path"; }
{name = "cmdline";} { name = "cmdline"; }
]; ];
}; };
}; };
settings = { settings = {
# Snippets # Snippets
snippet.expand = snippet.expand =
/* # lua
lua
*/
'' ''
function(args) require('luasnip').lsp_expand(args.body) end function(args) require('luasnip').lsp_expand(args.body) end
''; '';
@ -105,9 +101,7 @@ in {
]; ];
mapping = mapping =
mkRaw mkRaw
/* # lua
lua
*/
'' ''
cmp.mapping.preset.insert({ cmp.mapping.preset.insert({
["<C-n>"] = function(fallback) ["<C-n>"] = function(fallback)
@ -150,28 +144,31 @@ in {
conform-nvim = { conform-nvim = {
enable = true; enable = true;
formattersByFt = { formattersByFt = {
"_" = ["trim_whitespace"]; "_" = [ "trim_whitespace" ];
c = ["clang_format"]; c = [ "clang_format" ];
cpp = ["clang_format"]; cpp = [ "clang_format" ];
lua = ["stylua"]; lua = [ "stylua" ];
nix = ["alejandra"]; nix = [ "alejandra" ];
rust = ["rustfmt"]; rust = [ "rustfmt" ];
sh = ["shfmt"]; sh = [ "shfmt" ];
toml = ["taplo"]; toml = [ "taplo" ];
yaml = ["yamlfmt"]; yaml = [ "yamlfmt" ];
zig = ["zigfmt"]; zig = [ "zigfmt" ];
}; };
}; };
gitsigns.enable = true; gitsigns.enable = true;
lint = { lint = {
enable = true; enable = true;
lintersByFt = { lintersByFt = {
rust = ["typos"]; rust = [ "typos" ];
latex = ["chktex" "typos"]; latex = [
markdown = ["typos"]; "chktex"
nix = ["statix"]; "typos"
sh = ["dash"]; ];
zsh = ["zsh"]; markdown = [ "typos" ];
nix = [ "statix" ];
sh = [ "dash" ];
zsh = [ "zsh" ];
}; };
}; };
lsp = { lsp = {

View file

@ -1,5 +1,11 @@
{pkgs, ...}: { { pkgs, ... }:
imports = [./options.nix ./plugins.nix ./mappings.nix ./augroups.nix]; {
imports = [
./options.nix
./plugins.nix
./mappings.nix
./augroups.nix
];
config = { config = {
globals.mapleader = " "; globals.mapleader = " ";
@ -34,10 +40,12 @@
# Enable local configuration :h 'exrc' # Enable local configuration :h 'exrc'
exrc = true; # safe since nvim 0.9 exrc = true; # safe since nvim 0.9
}; };
extraPlugins = let extraPlugins =
let
plugins = pkgs.unstable.vimPlugins; plugins = pkgs.unstable.vimPlugins;
extraPlugins = import ./extraPlugins {pkgs = pkgs.unstable;}; extraPlugins = import ./extraPlugins { pkgs = pkgs.unstable; };
in [ in
[
plugins.nui-nvim plugins.nui-nvim
plugins.nvim-web-devicons plugins.nvim-web-devicons
extraPlugins.vim-jjdescription extraPlugins.vim-jjdescription

View file

@ -1,12 +1,13 @@
{stylix}: { { stylix }:
{
config, config,
pkgs, pkgs,
lib, lib,
... ...
}: let }:
let
cfg = config.jconfig; cfg = config.jconfig;
keysFromGithub = keysFromGithub = lib.attrsets.mapAttrs' (username: sha256: {
lib.attrsets.mapAttrs' (username: sha256: {
name = "pubkeys/${username}"; name = "pubkeys/${username}";
value = { value = {
mode = "0755"; mode = "0755";
@ -15,14 +16,14 @@
url = "https://github.com/${username}.keys"; url = "https://github.com/${username}.keys";
}; };
}; };
}) }) cfg.importSSHKeysFromGithub;
cfg.importSSHKeysFromGithub; in
in { {
imports = [ imports = [
./options.nix ./options.nix
./gui ./gui
stylix.nixosModules.stylix stylix.nixosModules.stylix
{stylix = import ./stylix-config.nix {inherit config pkgs;};} { stylix = import ./stylix-config.nix { inherit config pkgs; }; }
]; ];
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
@ -86,8 +87,8 @@ in {
users.defaultUserShell = pkgs.zsh; users.defaultUserShell = pkgs.zsh;
# Open ports for spotifyd # Open ports for spotifyd
networking.firewall = { networking.firewall = {
allowedUDPPorts = [5353]; allowedUDPPorts = [ 5353 ];
allowedTCPPorts = [2020]; allowedTCPPorts = [ 2020 ];
}; };
# Nix Settings # Nix Settings
nix = { nix = {

View file

@ -3,24 +3,24 @@
lib, lib,
pkgs, pkgs,
... ...
}: let }:
let
cfg = config.jconfig.gui; cfg = config.jconfig.gui;
enable = config.jconfig.enable && cfg.enable; enable = config.jconfig.enable && cfg.enable;
in { in
{
config = lib.mkMerge [ config = lib.mkMerge [
(lib.mkIf enable { (lib.mkIf enable {
environment.systemPackages = environment.systemPackages = [
[
pkgs.gnome.adwaita-icon-theme pkgs.gnome.adwaita-icon-theme
pkgs.adwaita-qt pkgs.adwaita-qt
pkgs.nordzy-cursor-theme pkgs.nordzy-cursor-theme
pkgs.pinentry-qt pkgs.pinentry-qt
] ] ++ lib.optional cfg.ydotool.enable pkgs.ydotool;
++ lib.optional cfg.ydotool.enable pkgs.ydotool;
systemd = { systemd = {
user.services.ydotool = lib.mkIf cfg.ydotool.enable { user.services.ydotool = lib.mkIf cfg.ydotool.enable {
enable = cfg.ydotool.autoStart; enable = cfg.ydotool.autoStart;
wantedBy = ["default.target"]; wantedBy = [ "default.target" ];
description = "Generic command-line automation tool"; description = "Generic command-line automation tool";
documentation = [ documentation = [
"man:ydotool(1)" "man:ydotool(1)"
@ -47,7 +47,7 @@ in {
sway = { sway = {
enable = cfg.sway; enable = cfg.sway;
# No extra packages (by default it adds foot, dmenu, and other stuff) # No extra packages (by default it adds foot, dmenu, and other stuff)
extraPackages = []; extraPackages = [ ];
wrapperFeatures = { wrapperFeatures = {
base = true; base = true;
gtk = true; gtk = true;
@ -77,7 +77,7 @@ in {
# XDG portals # XDG portals
enable = true; enable = true;
wlr.enable = true; wlr.enable = true;
extraPortals = [pkgs.xdg-desktop-portal-gtk]; extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
config.preferred = { config.preferred = {
# Default to the gtk portal # Default to the gtk portal
default = "gtk"; default = "gtk";

View file

@ -1,13 +1,16 @@
{lib, ...}: let { lib, ... }:
let
inherit (lib) types; inherit (lib) types;
# Like mkEnableOption but defaults to true # Like mkEnableOption but defaults to true
mkDisableOption = option: mkDisableOption =
option:
(lib.mkEnableOption option) (lib.mkEnableOption option)
// { // {
default = true; default = true;
example = false; example = false;
}; };
mkImageOption = { mkImageOption =
{
description, description,
url, url,
sha256 ? "", sha256 ? "",
@ -15,7 +18,7 @@
lib.mkOption { lib.mkOption {
inherit description; inherit description;
type = types.path; type = types.path;
default = builtins.fetchurl {inherit url sha256;}; default = builtins.fetchurl { inherit url sha256; };
defaultText = lib.literalMD "![${description}](${url})"; defaultText = lib.literalMD "![${description}](${url})";
}; };
@ -28,7 +31,7 @@
steamHardwareSupport = mkDisableOption "steam hardware support"; steamHardwareSupport = mkDisableOption "steam hardware support";
ydotool = lib.mkOption { ydotool = lib.mkOption {
description = "Jalil's default ydotool configuration."; description = "Jalil's default ydotool configuration.";
default = {}; default = { };
type = types.submodule { type = types.submodule {
options.enable = mkDisableOption "ydotool"; options.enable = mkDisableOption "ydotool";
options.autoStart = mkDisableOption "autostarting ydotool at login"; options.autoStart = mkDisableOption "autostarting ydotool at login";
@ -56,17 +59,17 @@
enable = lib.mkEnableOption "jalil's default configuration."; enable = lib.mkEnableOption "jalil's default configuration.";
dev = lib.mkOption { dev = lib.mkOption {
description = "Options for setting up a dev environment"; description = "Options for setting up a dev environment";
default = {}; default = { };
type = types.submodule {options.enable = lib.mkEnableOption "dev configuration";}; type = types.submodule { options.enable = lib.mkEnableOption "dev configuration"; };
}; };
gui = lib.mkOption { gui = lib.mkOption {
description = "Jalil's default configuration for a NixOS gui."; description = "Jalil's default configuration for a NixOS gui.";
default = {}; default = { };
type = types.submodule gui; type = types.submodule gui;
}; };
styling = lib.mkOption { styling = lib.mkOption {
description = "Jalil's styling options"; description = "Jalil's styling options";
default = {}; default = { };
type = types.submodule styling; type = types.submodule styling;
}; };
importSSHKeysFromGithub = lib.mkOption { importSSHKeysFromGithub = lib.mkOption {
@ -83,17 +86,18 @@
`users.users.<name>.openssh.authorizedKeys.keyFiles` on the users you `users.users.<name>.openssh.authorizedKeys.keyFiles` on the users you
want to allow ssh logins. want to allow ssh logins.
''; '';
default = {}; default = { };
example = { example = {
"jalil-salame" = "sha256:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; "jalil-salame" = "sha256:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
}; };
type = types.attrsOf types.str; type = types.attrsOf types.str;
}; };
}; };
in { in
{
options.jconfig = lib.mkOption { options.jconfig = lib.mkOption {
description = "Jalil's default NixOS configuration."; description = "Jalil's default NixOS configuration.";
default = {}; default = { };
type = types.submodule config; type = types.submodule config;
}; };
} }

View file

@ -1,9 +1,8 @@
{ { config, pkgs }:
config, let
pkgs,
}: let
cfg = config.jconfig.styling; cfg = config.jconfig.styling;
in { in
{
inherit (cfg) enable; inherit (cfg) enable;
image = cfg.wallpaper; image = cfg.wallpaper;
base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-dark-hard.yaml"; base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-dark-hard.yaml";