This commit is contained in:
Jan Bulthuis committed 2024-07-18 06:08:27 +02:00
1 parent bb7c74da4b
commit 1b4f8911fd
30 files changed
+1436 -928

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
{ lib, config, pkgs, ... }:
{
imports = [
./greetd/default.nix
./tuigreet/default.nix
./users/default.nix
];
}
+25
View File
@@ -0,0 +1,25 @@
{config, lib, pkgs, ... }:
with lib;
let
cfg = config.modules.greetd;
in {
options.modules.greetd = {
enable = mkEnableOption "greetd";
command = mkOption {
type = types.str;
default = "";
description = "Command to run to show greeter.";
};
};
config = mkIf cfg.enable {
services.greetd = {
enable = true;
settings.default_session = {
command = cfg.command;
user = "greeter";
};
};
};
}
View File
Whitespace-only changes.
+28
View File
@@ -0,0 +1,28 @@
{config, lib, pkgs, ... }:
with lib;
let
cfg = config.modules.tuigreet;
in {
options.modules.tuigreet = {
enable = mkEnableOption "tuigreet";
greeting = mkOption {
type = types.str;
default = "Hewwo! >_< :3";
description = "Greeting message to show.";
};
command = mkOption {
type = types.str;
default = "~/.initrc";
description = "Command to run after logging in.";
};
};
config = mkIf cfg.enable {
# Enable greetd
modules.greetd = {
enable = true;
command = "${pkgs.greetd.tuigreet}/bin/tuigreet --remember --greeting \"${cfg.greeting}\" --time --cmd \"${cfg.command}\" --asterisks";
};
};
}
+82
View File
@@ -0,0 +1,82 @@
{ config, lib, pkgs, ... }:
with lib;
let
# Nixvim
nixvim = import (builtins.fetchGit {
url = "https://github.com/nix-community/nixvim";
});
# Stylix
stylix = import (pkgs.fetchFromGitHub {
owner = "danth";
repo = "stylix";
rev = "1ff9d37d27377bfe8994c24a8d6c6c1734ffa116";
sha256 = "0dz8h1ga8lnfvvmvsf6iqvnbvxrvx3qxi0y8s8b72066mqgvy8y5";
});
# User configuration
userModule = types.submodule {
options = {
sudo = mkOption {
type = types.bool;
default = false;
example = true;
description = "Whether the user is allowed sudo access.";
};
configuration = mkOption {
type = types.path;
default = ./users/base.nix;
description = "What home manager configuration to use for this user.";
};
desktopInit = mkOption {
type = types.lines;
default = "";
description = "Bash script to execute after initial log in.";
};
};
};
in {
imports = [
# Import home manager
<home-manager/nixos>
# Import system configuration setup
# ./system.nix
];
options = {
machine.users = mkOption {
type = types.attrsOf userModule;
default = {};
description = "Users configured on this system.";
};
};
config = {
# Add required home manager modules
home-manager.sharedModules = [
# Stylix for theming
stylix.homeManagerModules.stylix
# Nixvim for neovim
nixvim.homeManagerModules.nixvim
# Modules
./modules/default.nix
];
# Create users
users.users = attrsets.concatMapAttrs (name: value: {
${name} = {
isNormalUser = true;
extraGroups = mkIf value.sudo [ "wheel" ];
};
}) config.machine.users;
# Create home manager configuration for users
home-manager.users = attrsets.concatMapAttrs (name: value: {
${name} = value.configuration;
}) config.machine.users;
};
}
+19
View File
@@ -0,0 +1,19 @@
{ input, pkgs, config, ... }:
{
# Set the state version
home.stateVersion = "24.05";
imports = [
# Import all modules
./desktop/default.nix
./feishin/default.nix
./firefox/default.nix
./obsidian/default.nix
./shell/bash.nix
./shell/fish.nix
./theming/default.nix
./vscode/default.nix
./zathura/default.nix
];
}
+31
View File
@@ -0,0 +1,31 @@
{ lib, pkgs, config, ... }:
with lib;
let
cfg = config.modules.desktop;
in {
imports = [
# Import desktop environment modules
./lock-screen/waylock.nix
./window-manager/river.nix
];
options.modules.desktop = {
initScript = mkOption {
type = types.lines;
default = "${pkgs.bash}/bin/bash";
description = "Bash script to execute after logging in.";
};
};
config = {
home.file.".initrc" = {
enable = true;
executable = true;
text = ''
#!${pkgs.bash}/bin/bash
'' + cfg.initScript;
};
};
}
@@ -0,0 +1,24 @@
{ lib, pkgs, config, ... }:
with lib;
let
cfg = config.modules.waylock;
in {
options.modules.waylock = {
enable = mkEnableOption "waylock";
system = mkOption {
type = types.attrsOf types.anything;
description = "System wide configuration to apply if module is enabled";
};
};
config = {
modules.waylock.system = mkForce {
security.pam.services.waylock = {};
};
home.packages = mkIf cfg.enable (with pkgs; [
waylock
]);
};
}
@@ -0,0 +1,171 @@
{config, lib, pkgs, ... }:
let
cfg = config.modules.river;
in {
options.modules.river.enable = lib.mkEnableOption "river";
# osConfig = lib.mkIf cfg.enable {
# programs.river.enable = true;
# };
config = lib.mkIf cfg.enable {
# Change desktop to execute river
modules.desktop.initScript = ''
river
'';
# River setup
wayland.windowManager.river = {
enable = true;
xwayland.enable = true;
settings = let
layout = "rivertile";
layoutOptions = "-outer-padding ${toString config.theming.layout.windowPadding} -view-padding ${toString config.theming.layout.windowPadding}";
modes = ["normal" "locked"];
tags = [1 2 3 4 5 6 7 8 9];
# TODO: Replace the base02 color with a named color
waylockOptions = "-init-color 0x${colors.bg} -input-color 0x${config.theming.schemeColors.base02} -fail-color 0x${colors.bg}";
colors = config.theming.colors;
# Quick pow function
pow2 = power:
if power != 0
then 2 * (pow2 (power - 1))
else 1;
# Modifiers
main = "Super";
ssm = "Super+Shift";
sas = "Super+Alt+Shift";
sam = "Super+Alt";
scm = "Super+Control";
scam = "Super+Control+Alt";
ssc = "Super+Shift+Control";
in {
default-layout = "${layout}";
set-repeat = "50 300";
xcursor-theme = "BreezeX-RosePine-Linux 24";
keyboard-layout = "-options \"caps:escape\" us";
border-width = toString config.theming.layout.borderSize;
background-color = "0x${colors.bg}";
border-color-focused = "0x${colors.fg}";
border-color-unfocused = "0x${config.theming.schemeColors.base01}"; # TODO: Change to use named color;
border-color-urgent = "0x${colors.fg}";
spawn = [
"\"${layout} ${layoutOptions}\""
"waybar"
];
map = (lib.attrsets.recursiveUpdate ({
normal = {
"${main} Q" = "close";
"${ssm} E" = "exit";
# Basic utilities
"${main} X " = "spawn \"waylock -fork-on-lock ${waylockOptions}\"";
"${ssm} Return" = "spawn foot";
"${main} P" = "spawn \"rofi -show drun\"";
"${ssm} P" = "spawn rofi-rbw";
# Window focus
"${main} J" = "focus-view next";
"${main} K" = "focus-view previous";
# Swap windows
"${ssm} J" = "swap next";
"${ssm} K" = "swap previous";
"${main} Return" = "zoom";
# Main ratio
"${main} H" = "send-layout-cmd rivertile 'main-ratio -0.05'";
"${main} L" = "send-layout-cmd rivertile 'main-ratio +0.05'";
# Main count
"${ssm} H" = "send-layout-cmd rivertile 'main-count +1'";
"${ssm} L" = "send-layout-cmd rivertile 'main-count -1'";
# Tags
"${main} 0" = "set-focused-tags ${toString (pow2 32 - 1)}";
"${ssm} 0" = "set-view-tags ${toString (pow2 32 - 1)}";
# Orientation
"${main} Up" = "send-layout-cmd rivertile \"main-location top\"";
"${main} Right" = "send-layout-cmd rivertile \"main-location right\"";
"${main} Down" = "send-layout-cmd rivertile \"main-location bottom\"";
"${main} Left" = "send-layout-cmd rivertile \"main-location left\"";
# Move floating windows
"${sam} H" = "move left 100";
"${sam} J" = "move down 100";
"${sam} K" = "move up 100";
"${sam} L" = "move right 100";
# Snap floating windows
"${scam} H" = "snap left";
"${scam} J" = "snap down";
"${scam} K" = "snap up";
"${scam} L" = "snap right";
# Resize floating windows
"${sas} H" = "resize horizontal -100";
"${sas} J" = "resize vertical 100";
"${sas} K" = "resize vertical -100";
"${sas} L" = "resize horizontal 100";
# Toggle modes
"${main} Space" = "toggle-float";
"${main} F" = "toggle-fullscreen";
} // builtins.listToAttrs (builtins.concatLists (map (tag: [
{ name = "${main} ${toString tag}"; value = "set-focused-tags ${toString (pow2 (tag - 1))}"; }
{ name = "${ssm} ${toString tag}"; value = "set-view-tags ${toString (pow2 (tag - 1))}"; }
{ name = "${scm} ${toString tag}"; value = "toggle-focused-tags ${toString (pow2 (tag - 1))}"; }
{ name = "${ssc} ${toString tag}"; value = "toggle-view-tags ${toString (pow2 (tag - 1))}"; }
]) tags));
}) (builtins.listToAttrs (map (mode: {
name = "${mode}";
value = {
# Control volume
"None XF86AudioRaiseVolume" = "spawn \"pulsemixer --change-volume +5\"";
"None XF86AudioLowerVolume" = "spawn \"pulsemixer --change-volume -5\"";
"None XF86AudioMute" = "spawn \"pulsemixer --toggle-mute\"";
# Control brightness
"None XF86MonBrightnessUp" = "spawn \"brightnessctl set +5%\"";
"None XF86MonBrightnessDown" = "spawn \"brightnessctl set 5%-\"";
# Control music playback
"None XF86Messenger" = "spawn \"playerctl previous\"";
"None XF86Go" = "spawn \"playerctl play-pause\"";
"None Cancel" = "spawn \"playerctl next\"";
};
}) modes)));
map-pointer = {
normal = {
"${main} BTN_LEFT" = "move-view";
"${main} BTN_RIGHT" = "resize-view";
"${main} BTN_MIDDLE" = "toggle-float";
};
};
input = {
"'*'" = {
accel-profile = "adaptive";
pointer-accel = "0.5";
scroll-factor = "0.8";
};
"'*Synaptics*'" = {
natural-scroll = "enabled";
};
};
rule-add = {
"-app-id" = {
"'bar'" = "csd";
"'*'" = "ssd";
};
};
};
};
};
}
+13
View File
@@ -0,0 +1,13 @@
{config, lib, pkgs, ... }:
let
cfg = config.modules.feishin;
in {
options.modules.feishin.enable = lib.mkEnableOption "feishin";
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
feishin
];
};
}
+60
View File
@@ -0,0 +1,60 @@
{config, lib, pkgs, ... }:
let
cfg = config.modules.firefox;
in {
options.modules.firefox.enable = lib.mkEnableOption "firefox";
config = lib.mkIf cfg.enable {
# Enable NUR
nixpkgs.config.packageOverrides = pkgs: {
# TODO: Pin the version
nur = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {
inherit pkgs;
};
};
programs.firefox = {
enable = true;
policies = {
AppAutoUpdate = false;
BlockAboutAddons = true;
BlockAboutConfig = true;
BlockAboutProfiles = true;
DisableAppUpdate = true;
DisableFeedbackCommands = true;
DisableMasterPasswordCreation = true;
DisablePocket = true;
DisableProfileImport = true;
DisableProfileRefresh = true;
DisableSetDesktopBackground = true;
DisableTelemetry = true;
DisplayBookmarksToolbar = "never";
DisplayMenuBar = "never";
DNSOverHTTPS = { Enabled = false; };
DontCheckDefaultBrowser = true;
PasswordManagerEnabled = false;
TranslateEnabled = true;
UseSystemPrintDialog = true;
};
profiles.nixos = {
search.default = "DuckDuckGo";
extensions = with pkgs.nur.repos.rycee.firefox-addons; [
ublock-origin
];
settings = {
"browser.tabs.inTitlebar" = 0;
"extensions.autoDisableScopes" = 0;
};
# Force overwriting configuration file
search.force = true;
containersForce = true;
};
};
};
}
@@ -0,0 +1,13 @@
{config, lib, pkgs, ... }:
let
cfg = config.modules.obsidian;
in {
options.modules.obsidian.enable = lib.mkEnableOption "obsidian";
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
obsidian
];
};
}
+12
View File
@@ -0,0 +1,12 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.modules.bash;
in {
options.modules.bash = {
enable = mkEnableOption "bash";
};
config.programs.bash.enable = cfg.enable;
}
+46
View File
@@ -0,0 +1,46 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.modules.fish;
in {
options.modules.fish = {
enable = mkEnableOption "fish";
plugins = {
done = mkEnableOption "done";
fzf = mkEnableOption "fzf";
grc = mkEnableOption "grc";
};
};
config = mkIf cfg.enable {
# Make bash load into fish
# Bash will remain the default shell as fish is not POSIX compliant.
modules.bash.enable = true;
programs.bash.initExtra = ''
if [[ $(${pkgs.procps}/bin/ps --no-header --pid=$PPID --format=comm) != "fish" && -z ''${BASH_EXECUTION_STRING} ]]
then
shopt -q login_shell && LOGIN_OPTION='--login' || LOGIN_OPTION=""
exec ${pkgs.fish}/bin/fish $LOGIN_OPTION
fi
'';
# Actual fish configuration
programs.fish = {
enable = true;
plugins = [
(mkIf cfg.plugins.done { name = "done"; src = pkgs.fishPlugins.done.src; })
(mkIf cfg.plugins.fzf { name = "fzf"; src = pkgs.fishPlugins.fzf-fish.src; })
(mkIf cfg.plugins.grc { name = "grc"; src = pkgs.fishPlugins.grc.src; })
];
};
# Fish plugin dependencies
home.packages = with pkgs; [
(mkIf cfg.plugins.fzf fzf)
(mkIf cfg.plugins.grc grc)
];
};
}
+83
View File
@@ -0,0 +1,83 @@
{ pkgs, lib, config, ... }:
with lib;
let
# Stylix
stylix = pkgs.fetchFromGitHub {
owner = "danth";
repo = "stylix";
rev = "1ff9d37d27377bfe8994c24a8d6c6c1734ffa116";
sha256 = "0dz8h1ga8lnfvvmvsf6iqvnbvxrvx3qxi0y8s8b72066mqgvy8y5";
};
in {
imports = [
# Import all themes
./themes/gruvbox.nix
./themes/catppuccin.nix
];
options.theming =
let
colors = config.theming.schemeColors;
in {
darkMode = mkOption {
type = types.bool;
default = false;
example = true;
description = "Whether the app should use dark mode.";
};
colorScheme = mkOption {
type = types.nullOr types.str;
default = null;
description = "Base 16 color scheme to use for styling. See stylix documentation for more information.";
};
schemeColors = mkOption {
type = types.attrsOf types.anything;
default = config.lib.stylix.colors;
description = "Generated colors from scheme";
};
colors = {
bg = mkOption {
type = types.str;
default = colors.base00;
};
fg = mkOption {
type = types.str;
default = colors.base05;
};
};
layout = {
borderRadius = mkOption {
type = types.int;
default = 0;
description = "Border radius of windows.";
};
borderSize = mkOption {
type = types.int;
default = 1;
description = "Size of borders used throughout UI.";
};
windowPadding = mkOption {
type = types.int;
default = 2;
description = "Margin of each window, actual space between windows will be twice this number.";
};
};
};
config = {
stylix = {
enable = true;
autoEnable = false;
base16Scheme = config.theming.colorScheme;
polarity = if config.theming.darkMode then "dark" else "light";
};
};
}
@@ -0,0 +1,22 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.theming.themes.catppuccin;
in {
options = {
theming.themes.catppuccin = {
enable = mkEnableOption "catppuccin";
flavor = mkOption {
type = types.enum [ "latte" "frappe" "macchiato" "mocha" ];
default = "mocha";
description = "The flavor of catppuccin theme.";
};
};
};
config.theming = mkIf cfg.enable {
darkMode = (cfg.flavor != "latte");
colorScheme = "${pkgs.base16-schemes}/share/themes/catppuccin-${cfg.flavor}.yaml";
};
}
@@ -0,0 +1,24 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.theming.themes.gruvbox;
mode = if cfg.darkMode then "dark" else "light";
in {
options = {
theming.themes.gruvbox = {
enable = mkEnableOption "gruvbox-hard";
darkMode = mkEnableOption "dark mode";
contrast = mkOption {
type = types.enum [ "hard" "medium" "soft" ];
default = "hard";
description = "The contrast level of the theme.";
};
};
};
config.theming = mkIf cfg.enable {
darkMode = cfg.darkMode;
colorScheme = "${pkgs.base16-schemes}/share/themes/gruvbox-${mode}-${cfg.contrast}.yaml";
};
}
+13
View File
@@ -0,0 +1,13 @@
{config, lib, pkgs, ... }:
let
cfg = config.modules.vscode;
in {
options.modules.vscode.enable = lib.mkEnableOption "vscode";
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
vscode
];
};
}
+17
View File
@@ -0,0 +1,17 @@
{config, lib, pkgs, ... }:
let
cfg = config.modules.zathura;
in {
options.modules.zathura.enable = lib.mkEnableOption "zathura";
config = lib.mkIf cfg.enable {
programs.zathura = {
enable = true;
options = {
guioptions = "none";
};
};
};
}
+13
View File
@@ -0,0 +1,13 @@
{ lib, config, pkgs, ... }:
with lib;
let
users = config.home-manager.users;
allModules = flatten (map (user: (attrValues user.modules)) (attrValues users));
modules = filter (module: module?system && module?enable) allModules;
configs = map (module: module.system) modules;
combined = (foldl (a: b: recursiveUpdate a b) {} configs);
in {
# Add the combined systemwide config required by the user modules.
config = combined;
}