refactor: move modules to their own dir
This commit is contained in:
parent
dda72854df
commit
addf563bfc
26 changed files with 86 additions and 60 deletions
127
modules/nixos/default.nix
Normal file
127
modules/nixos/default.nix
Normal file
|
@ -0,0 +1,127 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.jconfig;
|
||||
keysFromGithub = lib.attrsets.mapAttrs' (username: sha256: {
|
||||
name = "pubkeys/${username}";
|
||||
value = {
|
||||
mode = "0755";
|
||||
source = builtins.fetchurl {
|
||||
inherit sha256;
|
||||
url = "https://github.com/${username}.keys";
|
||||
};
|
||||
};
|
||||
}) cfg.importSSHKeysFromGithub;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./options.nix
|
||||
./gui
|
||||
{ stylix = import ./stylix-config.nix { inherit config pkgs; }; }
|
||||
];
|
||||
|
||||
config = lib.mkIf cfg.enable (
|
||||
lib.mkMerge [
|
||||
{
|
||||
boot.plymouth = {
|
||||
inherit (cfg.styling) enable;
|
||||
};
|
||||
|
||||
# Enable unlocking the gpg-agent at boot (configured through home.nix)
|
||||
security.pam.services.login.gnupg.enable = true;
|
||||
|
||||
environment.systemPackages = [
|
||||
# CLI tools
|
||||
pkgs.fd
|
||||
pkgs.ripgrep
|
||||
pkgs.du-dust
|
||||
pkgs.curl
|
||||
pkgs.zip
|
||||
pkgs.unzip
|
||||
];
|
||||
|
||||
# Enable dev documentation
|
||||
documentation.dev = {
|
||||
inherit (cfg.dev) enable;
|
||||
};
|
||||
programs = {
|
||||
# Shell prompt
|
||||
starship = {
|
||||
enable = true;
|
||||
settings = lib.mkMerge [
|
||||
{
|
||||
format = "$time$all";
|
||||
add_newline = false;
|
||||
cmd_duration.min_time = 500;
|
||||
cmd_duration.show_milliseconds = true;
|
||||
time.disabled = false;
|
||||
status = {
|
||||
format = "[$signal_name$common_meaning$maybe_int](red)";
|
||||
symbol = "[✗](bold red)";
|
||||
disabled = false;
|
||||
};
|
||||
sudo.disabled = false;
|
||||
}
|
||||
# Add nerdfont symbols
|
||||
(lib.mkIf cfg.styling.enable (import ./starship-nerdfont-symbols.nix))
|
||||
# Remove the `in`s and `on`s from the prompt
|
||||
(lib.mkIf cfg.styling.enable (import ./starship-shorter-text.nix))
|
||||
];
|
||||
};
|
||||
# Default shell
|
||||
zsh.enable = true;
|
||||
};
|
||||
|
||||
environment.etc = keysFromGithub;
|
||||
services = {
|
||||
# Enable printer autodiscovery if printing is enabled
|
||||
avahi = {
|
||||
inherit (config.services.printing) enable;
|
||||
nssmdns4 = true;
|
||||
openFirewall = true;
|
||||
};
|
||||
openssh.authorizedKeysFiles = builtins.map (path: "/etc/${path}") (
|
||||
builtins.attrNames keysFromGithub
|
||||
);
|
||||
};
|
||||
users.defaultUserShell = pkgs.zsh;
|
||||
# Open ports for spotifyd
|
||||
networking.firewall = {
|
||||
allowedUDPPorts = [ 5353 ];
|
||||
allowedTCPPorts = [ 2020 ];
|
||||
};
|
||||
# Nix Settings
|
||||
nix = {
|
||||
gc = {
|
||||
automatic = true;
|
||||
dates = "weekly";
|
||||
options = "--delete-older-than 30d";
|
||||
# run between 0 and 45min after boot if run was missed
|
||||
randomizedDelaySec = "45min";
|
||||
};
|
||||
settings = {
|
||||
use-xdg-base-directories = true;
|
||||
auto-optimise-store = true;
|
||||
experimental-features = [
|
||||
"nix-command"
|
||||
"flakes"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
# dev configuration
|
||||
(lib.mkIf cfg.dev.enable {
|
||||
users.extraUsers = lib.mkIf cfg.dev.jupyter.enable { jupyter.group = "jupyter"; };
|
||||
services.jupyter = {
|
||||
inherit (cfg.dev.jupyter) enable;
|
||||
group = "jupyter";
|
||||
user = "jupyter";
|
||||
};
|
||||
})
|
||||
]
|
||||
);
|
||||
}
|
118
modules/nixos/gui/default.nix
Normal file
118
modules/nixos/gui/default.nix
Normal file
|
@ -0,0 +1,118 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.jconfig.gui;
|
||||
enable = config.jconfig.enable && cfg.enable;
|
||||
linuxOlderThan6_3 = lib.versionOlder config.boot.kernelPackages.kernel.version "6.3";
|
||||
in
|
||||
{
|
||||
config = lib.mkMerge [
|
||||
(lib.mkIf enable {
|
||||
environment.systemPackages = [
|
||||
pkgs.adwaita-icon-theme
|
||||
pkgs.adwaita-qt
|
||||
pkgs.nordzy-cursor-theme
|
||||
pkgs.pinentry-qt
|
||||
] ++ lib.optional cfg.ydotool.enable pkgs.ydotool;
|
||||
systemd = {
|
||||
user.services.ydotool = lib.mkIf cfg.ydotool.enable {
|
||||
enable = cfg.ydotool.autoStart;
|
||||
wantedBy = [ "default.target" ];
|
||||
description = "Generic command-line automation tool";
|
||||
documentation = [
|
||||
"man:ydotool(1)"
|
||||
"man:ydotoold(8)"
|
||||
];
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
Restart = "always";
|
||||
ExecStart = "${pkgs.ydotool}/bin/ydotoold";
|
||||
ExecReload = "${pkgs.util-linux}/bin/kill -HUP $MAINPID";
|
||||
KillMode = "process";
|
||||
TimeoutSec = 180;
|
||||
};
|
||||
};
|
||||
# Fix xdg-portals issue issue: https://github.com/NixOS/nixpkgs/issues/189851
|
||||
user.extraConfig = ''
|
||||
DefaultEnvironment="PATH=/run/wrappers/bin:/etc/profiles/per-user/%u/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin"
|
||||
'';
|
||||
};
|
||||
|
||||
fonts.fontDir.enable = true;
|
||||
programs = {
|
||||
dconf.enable = true;
|
||||
sway = {
|
||||
enable = cfg.sway;
|
||||
# No extra packages (by default it adds foot, dmenu, and other stuff)
|
||||
extraPackages = [ ];
|
||||
wrapperFeatures = {
|
||||
base = true;
|
||||
gtk = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
security = {
|
||||
polkit.enable = true;
|
||||
rtkit.enable = true; # Recommended for pipewire
|
||||
};
|
||||
services = {
|
||||
flatpak.enable = true;
|
||||
# Audio
|
||||
pipewire = {
|
||||
enable = true;
|
||||
alsa = {
|
||||
enable = true;
|
||||
support32Bit = true;
|
||||
};
|
||||
pulse.enable = true;
|
||||
wireplumber.enable = true;
|
||||
};
|
||||
# Dbus
|
||||
dbus.enable = true;
|
||||
# Virtual Filesystem (for PCManFM)
|
||||
gvfs.enable = true;
|
||||
};
|
||||
xdg.portal = {
|
||||
# XDG portals
|
||||
enable = true;
|
||||
wlr.enable = true;
|
||||
extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
|
||||
config.preferred = {
|
||||
# Default to the gtk portal
|
||||
default = "gtk";
|
||||
# Use wlr for screenshots and screen recording
|
||||
"org.freedesktop.impl.portal.Screenshot" = "wlr";
|
||||
};
|
||||
# Consider using darkman like upstream
|
||||
};
|
||||
hardware = {
|
||||
graphics.enable = true;
|
||||
uinput.enable = true;
|
||||
steam-hardware.enable = cfg.steamHardwareSupport;
|
||||
};
|
||||
})
|
||||
(lib.mkIf (enable && linuxOlderThan6_3 && cfg."8bitdoFix") {
|
||||
# Udev rules to start or stop systemd service when controller is connected or disconnected
|
||||
services.udev.extraRules = # udev
|
||||
''
|
||||
# May vary depending on your controller model, find product id using 'lsusb'
|
||||
SUBSYSTEM=="usb", ATTR{idVendor}=="2dc8", ATTR{idProduct}=="3106", ATTR{manufacturer}=="8BitDo", RUN+="${pkgs.systemd}/bin/systemctl start 8bitdo-ultimate-xinput@2dc8:3106"
|
||||
# This device (2dc8:3016) is "connected" when the above device disconnects
|
||||
SUBSYSTEM=="usb", ATTR{idVendor}=="2dc8", ATTR{idProduct}=="3016", ATTR{manufacturer}=="8BitDo", RUN+="${pkgs.systemd}/bin/systemctl stop 8bitdo-ultimate-xinput@2dc8:3106"
|
||||
'';
|
||||
|
||||
# Systemd service which starts xboxdrv in xbox360 mode
|
||||
systemd.services."8bitdo-ultimate-xinput@" = {
|
||||
unitConfig.Description = "8BitDo Ultimate Controller XInput mode xboxdrv daemon";
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
ExecStart = "${pkgs.xboxdrv}/bin/xboxdrv --mimic-xpad --silent --type xbox360 --device-by-id %I --force-feedback";
|
||||
};
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
106
modules/nixos/options.nix
Normal file
106
modules/nixos/options.nix
Normal file
|
@ -0,0 +1,106 @@
|
|||
{ lib, ... }:
|
||||
let
|
||||
inherit (lib) types;
|
||||
# Like mkEnableOption but defaults to true
|
||||
mkDisableOption =
|
||||
option:
|
||||
(lib.mkEnableOption option)
|
||||
// {
|
||||
default = true;
|
||||
example = false;
|
||||
};
|
||||
mkImageOption =
|
||||
{
|
||||
description,
|
||||
url,
|
||||
sha256 ? "",
|
||||
}:
|
||||
lib.mkOption {
|
||||
inherit description;
|
||||
type = types.path;
|
||||
default = builtins.fetchurl { inherit url sha256; };
|
||||
defaultText = lib.literalMD "";
|
||||
};
|
||||
|
||||
gui.options = {
|
||||
enable = lib.mkEnableOption "jalil's default gui configuration.";
|
||||
# Fix for using Xinput mode on 8bitdo Ultimate C controller
|
||||
# Inspired by https://aur.archlinux.org/packages/8bitdo-ultimate-controller-udev
|
||||
# Adapted from: https://gist.github.com/interdependence/28452fbfbe692986934fbe1e54c920d4
|
||||
"8bitdoFix" = mkDisableOption "a fix for 8bitdo controllers";
|
||||
steamHardwareSupport = mkDisableOption "steam hardware support";
|
||||
ydotool = lib.mkOption {
|
||||
description = "Jalil's default ydotool configuration.";
|
||||
default = { };
|
||||
type = types.submodule {
|
||||
options.enable = mkDisableOption "ydotool";
|
||||
options.autoStart = mkDisableOption "autostarting ydotool at login";
|
||||
};
|
||||
};
|
||||
sway = mkDisableOption "sway";
|
||||
};
|
||||
|
||||
styling.options = {
|
||||
enable = mkDisableOption "jalil's default styling (disables stylix)";
|
||||
wallpaper = mkImageOption {
|
||||
description = "The wallpaper to use.";
|
||||
url = "https://raw.githubusercontent.com/lunik1/nixos-logo-gruvbox-wallpaper/d4937c424fad79c1136a904599ba689fcf8d0fad/png/gruvbox-dark-rainbow.png";
|
||||
sha256 = "036gqhbf6s5ddgvfbgn6iqbzgizssyf7820m5815b2gd748jw8zc";
|
||||
};
|
||||
bootLogo = mkImageOption {
|
||||
description = "The logo used by plymouth at boot.";
|
||||
# http://xenia-linux-site.glitch.me/images/cathodegaytube-splash.png
|
||||
url = "https://efimero.github.io/xenia-images/cathodegaytube-splash.png";
|
||||
sha256 = "qKugUfdRNvMwSNah+YmMepY3Nj6mWlKFh7jlGlAQDo8=";
|
||||
};
|
||||
};
|
||||
|
||||
config.options = {
|
||||
enable = lib.mkEnableOption "jalil's default configuration.";
|
||||
dev = lib.mkOption {
|
||||
description = "Options for setting up a dev environment";
|
||||
default = { };
|
||||
type = types.submodule {
|
||||
options.enable = lib.mkEnableOption "dev configuration";
|
||||
options.jupyter.enable = lib.mkEnableOption "jupyter configuration";
|
||||
};
|
||||
};
|
||||
gui = lib.mkOption {
|
||||
description = "Jalil's default configuration for a NixOS gui.";
|
||||
default = { };
|
||||
type = types.submodule gui;
|
||||
};
|
||||
styling = lib.mkOption {
|
||||
description = "Jalil's styling options";
|
||||
default = { };
|
||||
type = types.submodule styling;
|
||||
};
|
||||
importSSHKeysFromGithub = lib.mkOption {
|
||||
description = ''
|
||||
Import public ssh keys from a github username.
|
||||
|
||||
This will fetch the keys from https://github.com/$${username}.keys.
|
||||
|
||||
The format is `"$${github-username}" = $${sha256-hash}`. The example
|
||||
will try to fetch the keys from <https://github.com/jalil-salame.keys>.
|
||||
|
||||
**Warning**: this will interfere with services like gitea that override
|
||||
the default ssh behaviour. In that case you want to use
|
||||
`users.users.<name>.openssh.authorizedKeys.keyFiles` on the users you
|
||||
want to allow ssh logins.
|
||||
'';
|
||||
default = { };
|
||||
example = {
|
||||
"jalil-salame" = "sha256:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
|
||||
};
|
||||
type = types.attrsOf types.str;
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options.jconfig = lib.mkOption {
|
||||
description = "Jalil's default NixOS configuration.";
|
||||
default = { };
|
||||
type = types.submodule config;
|
||||
};
|
||||
}
|
89
modules/nixos/starship-nerdfont-symbols.nix
Normal file
89
modules/nixos/starship-nerdfont-symbols.nix
Normal file
|
@ -0,0 +1,89 @@
|
|||
{
|
||||
aws.symbol = " ";
|
||||
buf.symbol = " ";
|
||||
c.symbol = " ";
|
||||
conda.symbol = " ";
|
||||
crystal.symbol = " ";
|
||||
dart.symbol = " ";
|
||||
directory.read_only = " ";
|
||||
docker_context.symbol = " ";
|
||||
elixir.symbol = " ";
|
||||
elm.symbol = " ";
|
||||
fennel.symbol = " ";
|
||||
fossil_branch.symbol = " ";
|
||||
git_branch.symbol = " ";
|
||||
git_commit.tag_symbol = " ";
|
||||
golang.symbol = " ";
|
||||
gradle.symbol = " ";
|
||||
guix_shell.symbol = " ";
|
||||
haskell.symbol = " ";
|
||||
haxe.symbol = " ";
|
||||
hg_branch.symbol = " ";
|
||||
hostname.ssh_symbol = " ";
|
||||
java.symbol = " ";
|
||||
julia.symbol = " ";
|
||||
kotlin.symbol = " ";
|
||||
lua.symbol = " ";
|
||||
memory_usage.symbol = " ";
|
||||
meson.symbol = " ";
|
||||
nim.symbol = " ";
|
||||
nix_shell.symbol = " ";
|
||||
nodejs.symbol = " ";
|
||||
ocaml.symbol = " ";
|
||||
package.symbol = " ";
|
||||
perl.symbol = " ";
|
||||
php.symbol = " ";
|
||||
pijul_channel.symbol = " ";
|
||||
python.symbol = " ";
|
||||
rlang.symbol = " ";
|
||||
ruby.symbol = " ";
|
||||
rust.symbol = " ";
|
||||
scala.symbol = " ";
|
||||
swift.symbol = " ";
|
||||
zig.symbol = " ";
|
||||
os.symbols = {
|
||||
Alpaquita = " ";
|
||||
Alpine = " ";
|
||||
AlmaLinux = " ";
|
||||
Amazon = " ";
|
||||
Android = " ";
|
||||
Arch = " ";
|
||||
Artix = " ";
|
||||
CentOS = " ";
|
||||
Debian = " ";
|
||||
DragonFly = " ";
|
||||
Emscripten = " ";
|
||||
EndeavourOS = " ";
|
||||
Fedora = " ";
|
||||
FreeBSD = " ";
|
||||
Garuda = " ";
|
||||
Gentoo = " ";
|
||||
HardenedBSD = " ";
|
||||
Illumos = " ";
|
||||
Kali = " ";
|
||||
Linux = " ";
|
||||
Mabox = " ";
|
||||
Macos = " ";
|
||||
Manjaro = " ";
|
||||
Mariner = " ";
|
||||
MidnightBSD = " ";
|
||||
Mint = " ";
|
||||
NetBSD = " ";
|
||||
NixOS = " ";
|
||||
OpenBSD = " ";
|
||||
openSUSE = " ";
|
||||
OracleLinux = " ";
|
||||
Pop = " ";
|
||||
Raspbian = " ";
|
||||
Redhat = " ";
|
||||
RedHatEnterprise = " ";
|
||||
RockyLinux = " ";
|
||||
Redox = " ";
|
||||
Solus = " ";
|
||||
SUSE = " ";
|
||||
Ubuntu = " ";
|
||||
Unknown = " ";
|
||||
Void = " ";
|
||||
Windows = " ";
|
||||
};
|
||||
}
|
66
modules/nixos/starship-shorter-text.nix
Normal file
66
modules/nixos/starship-shorter-text.nix
Normal file
|
@ -0,0 +1,66 @@
|
|||
{
|
||||
aws.format = "[$symbol($profile)(\\($region\\))(\\[$duration\\])]($style) ";
|
||||
bun.format = "[$symbol($version)]($style) ";
|
||||
c.format = "[$symbol($version(-$name))]($style) ";
|
||||
cmake.format = "[$symbol($version)]($style) ";
|
||||
cmd_duration.format = "[⏱ $duration]($style) ";
|
||||
cobol.format = "[$symbol($version)]($style) ";
|
||||
conda.format = "[$symbol$environment]($style) ";
|
||||
crystal.format = "[$symbol($version)]($style) ";
|
||||
daml.format = "[$symbol($version)]($style) ";
|
||||
dart.format = "[$symbol($version)]($style) ";
|
||||
deno.format = "[$symbol($version)]($style) ";
|
||||
docker_context.format = "[$symbol$context]($style) ";
|
||||
dotnet.format = "[$symbol($version)(🎯 $tfm)]($style) ";
|
||||
elixir.format = "[$symbol($version \\(OTP $otp_version\\))]($style) ";
|
||||
elm.format = "[$symbol($version)]($style) ";
|
||||
erlang.format = "[$symbol($version)]($style) ";
|
||||
fennel.format = "[$symbol($version)]($style) ";
|
||||
fossil_branch.format = "[$symbol$branch]($style) ";
|
||||
gcloud.format = "[$symbol$account(@$domain)(\\($region\\))]($style) ";
|
||||
git_branch.format = "[$symbol$branch]($style) ";
|
||||
git_status.format = "[$all_status$ahead_behind]($style) ";
|
||||
golang.format = "[$symbol($version)]($style) ";
|
||||
gradle.format = "[$symbol($version)]($style) ";
|
||||
guix_shell.format = "[$symbol]($style) ";
|
||||
haskell.format = "[$symbol($version)]($style) ";
|
||||
haxe.format = "[$symbol($version)]($style) ";
|
||||
helm.format = "[$symbol($version)]($style) ";
|
||||
hg_branch.format = "[$symbol$branch]($style) ";
|
||||
java.format = "[$symbol($version)]($style) ";
|
||||
julia.format = "[$symbol($version)]($style) ";
|
||||
kotlin.format = "[$symbol($version)]($style) ";
|
||||
kubernetes.format = "[$symbol$context( \\($namespace\\))]($style) ";
|
||||
lua.format = "[$symbol($version)]($style) ";
|
||||
memory_usage.format = "$symbol[$ram( | $swap)]($style) ";
|
||||
meson.format = "[$symbol$project]($style) ";
|
||||
nim.format = "[$symbol($version)]($style) ";
|
||||
nix_shell.format = "[$symbol$state( \\($name\\))]($style) ";
|
||||
nodejs.format = "[$symbol($version)]($style) ";
|
||||
ocaml.format = "[$symbol($version)(\\($switch_indicator$switch_name\\))]($style) ";
|
||||
opa.format = "[$symbol($version)]($style) ";
|
||||
openstack.format = "[$symbol$cloud(\\($project\\))]($style) ";
|
||||
os.format = "[$symbol]($style) ";
|
||||
package.format = "[$symbol$version]($style) ";
|
||||
perl.format = "[$symbol($version)]($style) ";
|
||||
php.format = "[$symbol($version)]($style) ";
|
||||
pijul_channel.format = "[$symbol$channel]($style) ";
|
||||
pulumi.format = "[$symbol$stack]($style) ";
|
||||
purescript.format = "[$symbol($version)]($style) ";
|
||||
python.format = "[\${symbol}\${pyenv_prefix}(\${version})(\\($virtualenv\\))]($style) ";
|
||||
raku.format = "[$symbol($version-$vm_version)]($style) ";
|
||||
red.format = "[$symbol($version)]($style) ";
|
||||
ruby.format = "[$symbol($version)]($style) ";
|
||||
rust.format = "[$symbol($version)]($style) ";
|
||||
scala.format = "[$symbol($version)]($style) ";
|
||||
spack.format = "[$symbol$environment]($style) ";
|
||||
sudo.format = "[as $symbol]($style) ";
|
||||
swift.format = "[$symbol($version)]($style) ";
|
||||
terraform.format = "[$symbol$workspace]($style) ";
|
||||
time.format = "[$time]($style) ";
|
||||
username.format = "[$user]($style) ";
|
||||
vagrant.format = "[$symbol($version)]($style) ";
|
||||
vlang.format = "[$symbol($version)]($style) ";
|
||||
zig.format = "[$symbol($version)]($style) ";
|
||||
solidity.format = "[$symbol($version)]($style) ";
|
||||
}
|
36
modules/nixos/stylix-config.nix
Normal file
36
modules/nixos/stylix-config.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{ config, pkgs }:
|
||||
let
|
||||
cfg = config.jconfig.styling;
|
||||
in
|
||||
{
|
||||
inherit (cfg) enable;
|
||||
image = cfg.wallpaper;
|
||||
base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-dark-hard.yaml";
|
||||
polarity = "dark";
|
||||
fonts = {
|
||||
monospace = {
|
||||
name = "JetBrains Mono";
|
||||
package = pkgs.jetbrains-mono;
|
||||
};
|
||||
sansSerif = {
|
||||
name = "Noto Sans";
|
||||
package = pkgs.noto-fonts;
|
||||
};
|
||||
serif = {
|
||||
name = "Noto Serif";
|
||||
package = pkgs.noto-fonts;
|
||||
};
|
||||
emoji = {
|
||||
package = pkgs.noto-fonts-emoji;
|
||||
name = "Noto Color Emoji";
|
||||
};
|
||||
sizes.popups = 12;
|
||||
};
|
||||
targets = {
|
||||
plymouth = {
|
||||
logoAnimated = false;
|
||||
logo = cfg.bootLogo;
|
||||
};
|
||||
nixvim.enable = false;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue