fix: Rename ./nixos to ./system

This makes it clearer that it is the system configuration.
This commit is contained in:
Jalil David Salamé Messina 2024-02-18 15:43:37 +01:00
parent 96008a0fcc
commit 00e193c0d4
Signed by: jalil
GPG key ID: F016B9E770737A0B
6 changed files with 2 additions and 2 deletions

84
system/default.nix Normal file
View file

@ -0,0 +1,84 @@
{ stylix }: { 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.nixosModules.stylix
# FIXME(https://github.com/danth/stylix/issues/216): Must configure stylix
{ stylix = import ./stylix-config.nix { inherit config pkgs; }; }
];
config = lib.mkIf cfg.enable {
boot.plymouth.enable = cfg.styling.enable;
# Enable unlocking the gpg-agent at boot (configured through home.nix)
security.pam.services.login.gnupg.enable = true;
environment.systemPackages = [
# Dev tools
pkgs.gcc
pkgs.clang
# CLI tools
pkgs.fd
pkgs.bat
pkgs.skim
pkgs.ripgrep
pkgs.du-dust
pkgs.curl
pkgs.wget
pkgs.eza
pkgs.zip
pkgs.unzip
];
# Shell prompt
programs.starship.enable = true;
programs.starship.settings = lib.mkIf cfg.styling.enable {
format = "$time$all";
add_newline = false;
cmd_duration.min_time = 500;
cmd_duration.show_milliseconds = true;
time.format = "[$time](bold yellow) ";
time.disabled = false;
status.format = "[$signal_name$common_meaning$maybe_int](red)";
status.symbol = "[](bold red)";
status.disabled = false;
sudo.disabled = false;
};
environment.etc = keysFromGithub;
services.openssh.authorizedKeysFiles = builtins.map (path: "/etc/${path}") (builtins.attrNames keysFromGithub);
# Default shell
programs.zsh.enable = true;
users.defaultUserShell = pkgs.zsh;
# Open ports for spotifyd
networking.firewall.allowedUDPPorts = [ 5353 ];
networking.firewall.allowedTCPPorts = [ 2020 ];
# Nix Settings
nix.gc.automatic = true;
nix.gc.dates = "weekly";
nix.gc.options = "--delete-older-than 30d";
# run between 0 and 45min after boot if run was missed
nix.gc.randomizedDelaySec = "45min";
nix.settings.auto-optimise-store = true;
nix.settings.experimental-features = [ "nix-command" "flakes" ];
};
}

91
system/gui/default.nix Normal file
View file

@ -0,0 +1,91 @@
{ config, lib, pkgs, ... }:
let
cfg = config.jconfig.gui;
enable = config.jconfig.enable && cfg.enable;
in
{
config = lib.mkMerge [
(lib.mkIf enable {
environment.systemPackages = [
pkgs.gnome.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
systemd.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;
programs.sway.enable = cfg.sway;
programs.sway.extraPackages = [ ]; # No extra packages (by default it adds foot, dmenu, and other stuff)
programs.sway.wrapperFeatures.base = true;
programs.sway.wrapperFeatures.gtk = true;
security.polkit.enable = true;
security.rtkit.enable = true; # Recommended for pipewire
services.flatpak.enable = true;
# Audio
services.pipewire.enable = true;
services.pipewire.alsa.enable = true;
services.pipewire.alsa.support32Bit = true;
services.pipewire.pulse.enable = true;
services.pipewire.wireplumber.enable = true;
# Dbus
services.dbus.enable = true;
# XDG portals
xdg.portal.enable = true;
xdg.portal.wlr.enable = true;
xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
# Default to the gtk portal
xdg.portal.config.preferred.default = "gtk";
# Use wlr for screenshots and screen recording
xdg.portal.config.preferred."org.freedesktop.impl.portal.Screenshot" = "wlr";
xdg.portal.config.preferred."org.freedesktop.impl.portal.ScreenCast" = "wlr";
# Consider using darkman like upstream
hardware.opengl.enable = true;
hardware.uinput.enable = true;
hardware.steam-hardware.enable = cfg.steamHardwareSupport;
})
(lib.mkIf (enable && cfg."8bitdoFix") {
# Udev rules to start or stop systemd service when controller is connected or disconnected
services.udev.extraRules = ''
# 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";
};
};
})
];
}

89
system/options.nix Normal file
View file

@ -0,0 +1,89 @@
{ lib, ... }:
let
inherit (lib) types;
# Like mkEnableOption but defaults to true
mkDisableOption = option: lib.mkOption {
description = lib.mdDoc "Whether to enable ${option}.";
type = types.bool;
default = true;
example = false;
};
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 = lib.mdDoc "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 (cannot be disabled currently)";
wallpaper = lib.mkOption {
description = "The wallpaper to use.";
type = types.str;
default = builtins.fetchurl {
url = "https://raw.githubusercontent.com/lunik1/nixos-logo-gruvbox-wallpaper/d4937c424fad79c1136a904599ba689fcf8d0fad/png/gruvbox-dark-rainbow.png";
sha256 = "036gqhbf6s5ddgvfbgn6iqbzgizssyf7820m5815b2gd748jw8zc";
};
};
bootLogo = lib.mkOption {
description = "The logo used by plymouth at boot.";
type = types.str;
# http://xenia-linux-site.glitch.me/images/cathodegaytube-splash.png
default = builtins.fetchurl {
url = "https://efimero.github.io/xenia-images/cathodegaytube-splash.png";
sha256 = "qKugUfdRNvMwSNah+YmMepY3Nj6mWlKFh7jlGlAQDo8=";
};
};
};
config.options = {
enable = lib.mkEnableOption "jalil's default configuration.";
gui = lib.mkOption {
description = lib.mdDoc "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 = lib.mdDoc ''
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 = lib.mdDoc "Jalil's default NixOS configuration.";
default = { };
type = types.submodule config;
};
}

31
system/stylix-config.nix Normal file
View file

@ -0,0 +1,31 @@
{ config, pkgs }:
let
cfg = config.jconfig.styling;
nerdFontSymbols = pkgs.nerdfonts.override { fonts = [ "NerdFontsSymbolsOnly" ]; };
fallbackSymbols = {
name = "Symbols Nerd Font";
package = nerdFontSymbols;
};
in
{
autoEnable = 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; }
fallbackSymbols
];
fonts.sansSerif = [
{ name = "Noto Sans"; package = pkgs.noto-fonts; }
fallbackSymbols
];
fonts.serif = [
{ name = "Noto Serif"; package = pkgs.noto-fonts; }
fallbackSymbols
];
fonts.emoji = { package = pkgs.noto-fonts-emoji; name = "Noto Color Emoji"; };
fonts.sizes.popups = 12;
targets.plymouth.logoAnimated = false;
targets.plymouth.logo = cfg.bootLogo;
}