Modularize nixos and home-manager packages

This commit is contained in:
DashieTM 2024-08-03 18:08:22 +02:00
parent b0979afa53
commit 51d2c2aa7c
32 changed files with 713 additions and 482 deletions

View file

@ -0,0 +1,104 @@
{ config, lib, options, pkgs, ... }: {
options.mods = {
default_base_packages = {
enable = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = ''
Enables default system packages.
'';
};
additional_packages = lib.mkOption {
default = [ ];
example = [ pkgs.openssl ];
type = with lib.types; listOf packages;
description = ''
Additional packages to install.
Note that these are installed even if base packages is disabled, e.g. you can also use this as the only packages to install.
'';
};
};
};
config =
(lib.optionalAttrs (options?environment.systemPackages)
{
environment.systemPackages = config.mods.default_base_packages.additional_packages;
} // (lib.mkIf config.mods.default_base_packages.enable (
lib.optionalAttrs
(options?environment.systemPackages)
{
environment.systemPackages = with pkgs; [
openssl
dbus
glib
gtk4
gtk3
libadwaita
gtk-layer-shell
gtk4-layer-shell
direnv
dconf
gsettings-desktop-schemas
gnome.nixos-gsettings-overrides
bibata-cursors
xorg.xkbutils
libxkbcommon
icon-library
adwaita-icon-theme
hicolor-icon-theme
morewaita-icon-theme
kdePackages.breeze-icons
seahorse
upower
(lib.mkIf config.conf.streamdeck.enable (callPackage
../../override/streamdeck.nix
{ }))
];
gtk.iconCache.enable = false;
fonts.packages = with pkgs; [
cantarell-fonts
];
nix.settings.experimental-features = "nix-command flakes";
virtualisation.docker.enable = true;
services.upower.enable = true;
services.dbus.enable = true;
services.dbus.packages = with pkgs; [
gnome2.GConf
];
services.avahi = {
enable = true;
nssmdns4 = true;
openFirewall = true;
};
programs.fish.enable = true;
programs.fish.promptInit = ''
${pkgs.any-nix-shell}/bin/any-nix-shell fish --info-right | source
'';
programs.nix-ld.enable = true;
programs.nix-ld.libraries = with pkgs; [
jdk
zlib
];
programs.direnv = {
package = pkgs.direnv;
silent = false;
loadInNixShell = true;
direnvrcExtra = "";
nix-direnv = {
enable = true;
package = pkgs.nix-direnv;
};
};
programs.ssh.startAgent = true;
programs.gnupg.agent.enable = true;
})));
}

134
modules/programs/coding.nix Normal file
View file

@ -0,0 +1,134 @@
{ lib, config, pkgs, options, ... }: {
options.mods = {
coding = {
enable = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = ''
Enables coding packages.
'';
};
dashvim = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = ''
Enables dashvim package.
'';
};
};
};
config = lib.mkIf config.mods.coding.enable (lib.optionalAttrs (options?home.packages) {
programs.dashvim = lib.mkIf config.mods.coding.dashvim {
enable = true;
colorscheme = config.conf.colorscheme;
};
home.packages = with pkgs; [
#basics
gitui
gcc
meson
ninja
tree-sitter
unzip
pkg-config
sqlite
plantuml
d-spy
# cpp
bear
clang-tools
#sql
nodePackages.sql-formatter
sqls
#assembly
asm-lsp
#yaml
yamlfmt
yamllint
yaml-language-server
#markdown
marksman
mdformat
#bash
bash-language-server
shfmt
#fsharp
fsharp
fsautocomplete
#haskell
haskellPackages.cabal-install
ghc
haskellPackages.haskell-language-server
#html
html-tidy
#json
jq
nodePackages.vscode-json-languageserver
#css
tailwindcss
tailwindcss-language-server
vscode-langservers-extracted
#editors
neovide
##fallback
vscodium
#rust
rustup
#python
python3
python312Packages.python-lsp-server
python312Packages.python-lsp-ruff
python312Packages.python-lsp-black
#ts/js
nodejs_20
deno
typescript
nodePackages.typescript-language-server
nodePackages.prettier
#go
go
gopls
#typst
typst
tinymist
ltex-ls
#java
gradle
maven
jdt-language-server
temurin-jre-bin
#.!
dotnet-sdk_8
omnisharp-roslyn
csharpier
netcoredbg
#zig
zig
zls
];
});
}

View file

@ -7,5 +7,14 @@
./drives.nix
./bluetooth.nix
./acpid.nix
./piper.nix
./greetd.nix
./gnome_services.nix
./printing.nix
./layout.nix
./base_packages.nix
./home_packages.nix
./media.nix
./flatpak.nix
];
}

View file

@ -0,0 +1,31 @@
{ lib, config, options, pkgs, ... }: {
options.mods.flatpak = {
enable = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = "Enables the flatpak package manager";
};
additional_packages = lib.mkOption {
default = [ ];
example = [ ];
type = with lib.types; listOf str;
description = "Flatpak packages";
};
};
config = lib.mkIf config.mods.flatpak.enable
(lib.optionalAttrs (options?services.flatpak.remote)
{
services.flatpak.remotes = lib.mkOptionDefault [{
name = "flathub-stable";
location = "https://dl.flathub.org/repo/flathub.flatpakrepo";
}];
services.flatpak.uninstallUnmanaged = true;
} // lib.optionalAttrs (options?services.flatpak.packages) {
services.flatpak.packages = [
# fallback if necessary, but generally avoided as nix is superior :)
# default flatseal installation since flatpak permissions are totally not a broken idea
"com.github.tchx84.Flatseal"
] ++ config.mods.flatpak.additional_packages;
});
}

View file

@ -0,0 +1,28 @@
{ lib, config, options, pkgs, ... }: {
options.mods = {
gnome_services.enable = lib.mkOption {
default = true;
type = lib.types.bool;
example = false;
description = ''
Enables gnome services: keyring and settings daemon.
Note: Do not use these for environments which ship these functionalities by default: GNOME, KDE
'';
};
};
config = lib.mkIf config.mods.gnome_services.enable (lib.optionalAttrs (options?services.gnome.gnome-keyring) {
programs.dconf.enable = true;
services = {
# needed for GNOME services outside of GNOME Desktop
dbus.packages = with pkgs; [
gcr
gnome.gnome-settings-daemon
];
gnome.gnome-keyring.enable = true;
gvfs.enable = true;
};
});
}

View file

@ -0,0 +1,99 @@
{ config, lib, inputs, pkgs, options, ... }: {
options.mods = {
greetd = {
enable = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = ''
Enables the greetd login manager.
'';
};
monitor = lib.mkOption {
default = "${config.conf.monitor}";
example = "eDP-1";
type = lib.types.str;
description = ''
main monitor for the login screen.
By default the main monitor is used.
'';
};
scale = lib.mkOption {
default = "${config.conf.scale}";
example = "1.5";
type = lib.types.str;
description = ''
Scale used by the monitor in the login screen.
By default the scale of the main monitor is used.
'';
};
resolution = lib.mkOption {
default = "auto";
example = "3440x1440@180";
type = lib.types.str;
description = ''
Resolution/refreshrate used by the monitor in the login screen.
'';
};
};
};
config =
let
username = config.conf.username;
session = {
command = "${lib.getExe inputs.hyprland.packages.${config.conf.system}.hyprland} --config /etc/greetd/hyprgreet.conf";
user = username;
};
in
lib.mkIf config.mods.greetd.enable
(lib.optionalAttrs (options?environment) {
services.xserver.displayManager.session = [
{
manage = "desktop";
name = "Hyprland";
start = ''
${lib.getExe pkgs.hyprland} & waitPID=$!
'';
}
];
# greetd display manager
programs.hyprland.enable = true;
services.greetd = {
enable = true;
settings = {
terminal.vt = 1;
default_session = session;
};
};
environment.etc."greetd/environments".text = ''
Hyprland
'';
# should technically be the same, but this is configured instead in order to provide a decent out of the box login experience.
environment.etc."greetd/hyprgreet.conf".text = ''
exec-once=gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
monitor=${config.mods.greetd.monitor},${config.mods.greetd.resolution},0x0,${config.mods.greetd.scale}
monitor=_,disable
input {
kb_layout = ${config.mods.xkb.layout}
kb_variant = ${config.mods.xkb.variant}
force_no_accel = true
}
misc {
disable_splash_rendering = false
disable_hyprland_logo = false
}
exec-once=regreet --style /home/${username}/.config/gtk-3.0/gtk.css; hyprctl dispatch exit
'';
# unlock GPG keyring on login
security.pam.services.greetd.enableGnomeKeyring = true;
});
}

View file

@ -0,0 +1,93 @@
{ lib, options, config, pkgs, inputs, ... }: {
options.mods.home_packages = {
enable = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = "Home manager packages";
};
additional_packages = lib.mkOption {
default = [ ];
example = [ pkgs.flatpak ];
type = lib.types.str;
description = ''
Additional Home manager packages.
Will be installed regardless of default home manager packages are installed.
'';
};
};
config =
let
callPackage = lib.callPackageWith pkgs;
in
(lib.optionalAttrs (options?home.packages)
{
home.packages = config.mods.home_packages.additional_packages;
} // (lib.mkIf config.mods.home_packages.enable (lib.optionalAttrs (options?home.packages) {
home.packages = with pkgs; [
keepassxc
nheko
nextcloud-client
xournalpp
vesktop
kitty
fish
ripgrep
rm-improved
bat
fd
lsd
(nerdfonts.override { fonts = [ "JetBrainsMono" ]; })
noto-fonts
flatpak
networkmanager
zoxide
fastfetch
gnome-keyring
dbus
killall
adw-gtk3
qt5ct
qt6ct
gnutar
fishPlugins.tide
nix-index
libnotify
zenith
nh
amberol
pulseaudio
playerctl
ncspot
poppler_utils
brave
greetd.regreet
sops
flake-checker
ffmpeg
system-config-printer
brightnessctl
(callPackage
../../override/cambalache.nix
{ })
];
#my own programs
programs.oxicalc.enable = true;
programs.oxinoti.enable = true;
programs.oxidash.enable = true;
programs.oxishut.enable = true;
programs.oxipaste.enable = true;
programs.hyprdock.enable = true;
programs.ReSet.enable = true;
programs.ReSet.config.plugins = [
inputs.reset-plugins.packages."x86_64-linux".monitor
inputs.reset-plugins.packages."x86_64-linux".keyboard
];
programs.ReSet.config.plugin_config = {
Keyboard = {
path = "/home/${config.conf.username}/.config/reset/keyboard.conf";
};
};
})));
}

View file

@ -0,0 +1,23 @@
{ lib, options, config, ... }: {
options.mods.xkb = {
layout = lib.mkOption {
default = "dashie";
example = "us";
type = lib.types.str;
description = "Your layout";
};
variant = lib.mkOption {
default = "";
example = "";
type = lib.types.str;
description = "Your variant";
};
};
config = (lib.optionalAttrs (options?services.xserver) {
# Configure keymap in X11
services.xserver = {
xkb.layout = "${config.mods.xkb.layout}";
xkb.variant = "${config.mods.xkb.variant}";
};
});
}

View file

@ -0,0 +1,56 @@
{ lib, options, config, pkgs, ... }: {
options.mods.media_packages = {
enable = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = "Default media packages";
};
additional_packages = lib.mkOption {
default = [ ];
example = [ pkgs.flatpak ];
type = lib.types.str;
description = ''
Additional media packages.
Will be installed regardless of default media packages are installed.
'';
};
};
config =
(lib.optionalAttrs (options?home.packages)
{
home.packages = config.mods.media_packages.additional_packages;
} // (lib.mkIf config.mods.media_packages.enable (lib.optionalAttrs (options?home.packages) {
home.packages = with pkgs; [
# base audio
pipewire
wireplumber
# audio control
playerctl
# images
imv
# videos
mpv
# pdf
zathura
evince
libreoffice-fresh
onlyoffice-bin
pdftk
pdfpc
polylux2pdfpc
# spotify
# video editing
kdenlive
# image creation
inkscape
gimp
krita
yt-dlp
];
programs.obs-studio.enable = true;
programs.obs-studio.plugins = with pkgs; [
obs-studio-plugins.obs-vaapi
];
})));
}

View file

@ -0,0 +1,19 @@
{ lib, config, options, pkgs, ... }: {
options.mods.piper = {
enable = lib.mkOption {
default = false;
example = true;
type = lib.types.bool;
description = "Enables the piper program and its daemon";
};
};
config = lib.mkIf config.mods.piper.enable
(lib.optionalAttrs (options?services.ratbagd)
{
services.ratbagd.enable = true;
} // lib.optionalAttrs (options?home.packages) {
home.packages = with pkgs; [
piper
];
});
}

View file

@ -0,0 +1,24 @@
{ lib, config, options, pkgs, ... }: {
options.mods.printing = {
enable = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = "Enables the piper program and its daemon";
};
};
config = lib.mkIf config.mods.printing.enable
(lib.optionalAttrs (options?services.printing)
{
# Enable CUPS to print documents.
services.printing.enable = true;
services.printing.browsing = true;
services.printing.drivers = [ pkgs.hplip ];
services.printing.startWhenNeeded = true; # optional
services.avahi = {
enable = true;
nssmdns4 = true;
openFirewall = true;
};
});
}