From 29cff10a45459766844419c6825dbfe4e8470e71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Sun, 14 Jan 2024 17:33:16 +0100 Subject: [PATCH] feat: Initial commit --- .gitignore | 2 + configuration/default.nix | 99 +++++++++++++ configuration/gui/default.nix | 105 +++++++++++++ configuration/stylix-config.nix | 26 ++++ flake.lock | 254 ++++++++++++++++++++++++++++++++ flake.nix | 36 +++++ 6 files changed, 522 insertions(+) create mode 100644 .gitignore create mode 100644 configuration/default.nix create mode 100644 configuration/gui/default.nix create mode 100644 configuration/stylix-config.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4812d58 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +result +.direnv/ diff --git a/configuration/default.nix b/configuration/default.nix new file mode 100644 index 0000000..a530414 --- /dev/null +++ b/configuration/default.nix @@ -0,0 +1,99 @@ +{ stylix }: { config, pkgs, lib, ... }: +let + inherit (lib) types; + cfg = config.jconfig; + mkDisableOption = option: lib.mkOption { + description = lib.mdDoc "Whether to enable ${option}."; + type = types.bool; + default = true; + example = false; + }; +in +{ + imports = [ ./gui ] ++ lib.optional (cfg.enable && cfg.styling.enable) stylix.homeManagerModules.stylix; + + options.jconfig = lib.mkOption { + description = lib.mdDoc "Jalil's default NixOS configuration."; + type = types.submodule { + options.enable = lib.mkEnableOption "jalil's default configuration."; + options.styling = lib.mkOption { + description = "Jalil's styling options"; + type = types.submodule { + options.enable = mkDisableOption "jalil's default styling"; + options.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"; + }; + }; + options.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 = lib.optionalAttrs cfg.enable { + boot.plymouth.enable = cfg.styling.enable; + stylix = lib.optionalAttrs cfg.styling.enable (import ./stylix-config.nix); + + # 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.just + pkgs.clang + # CLI tools + pkgs.fd + pkgs.bat + pkgs.skim + pkgs.ripgrep + pkgs.du-dust + pkgs.curl + pkgs.wget + pkgs.eza + ]; + + # Shell prompt + programs.starship.enable = true; + programs.starship.settings = lib.optionalAttrs 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; + }; + # 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" ]; + }; +} diff --git a/configuration/gui/default.nix b/configuration/gui/default.nix new file mode 100644 index 0000000..e66af52 --- /dev/null +++ b/configuration/gui/default.nix @@ -0,0 +1,105 @@ +{ config, lib, pkgs, ... }: +let + inherit (lib) types; + cfg = config.jconfig.gui; + enable = config.jconfig.enable && cfg.enable; + # Like lib.mkEnableOption but default to true + mkDisableOption = option: lib.mkOption { + description = lib.mdDoc "Whether to enable ${option}."; + type = types.bool; + default = true; + example = false; + }; +in +{ + options.jhome.gui = lib.mkOption { + description = lib.mdDoc "Jalil's default configuration for a NixOS gui."; + type = types.submodule { + 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 + options."8bitdoFix" = mkDisableOption "a fix for 8bitdo controllers"; + options.steamHardwareSupport = mkDisableOption "steam hardware support"; + options.ydotool = lib.mkOption { + description = lib.mdDoc "Jalil's default ydotool configuration."; + type = types.submodule { + options.enable = mkDisableOption "ydotool"; + options.autoStart = mkDisableOption "autostarting ydotool at login"; + }; + }; + }; + }; + + config = lib.optionalAttrs 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.optionalAttrs 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; + }; + }; + + fonts.fontDir.enable = true; + + # Backlight control + programs.light.enable = true; + programs.dconf.enable = 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 ]; + xdg.portal.config.preferred.default = "wlr"; # Default to wlr + xdg.portal.config.preferred."org.freedesktop.impl.portal.FileChooser" = "gtk"; # But choose files with "gtk" + + hardware.opengl.enable = true; + hardware.uinput.enable = true; + hardware.steam-hardware.enable = cfg.steamHardwareSupport; + } // lib.optionalAttrs 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"; + }; + }; + }; +} diff --git a/configuration/stylix-config.nix b/configuration/stylix-config.nix new file mode 100644 index 0000000..7411910 --- /dev/null +++ b/configuration/stylix-config.nix @@ -0,0 +1,26 @@ +{ config, pkgs, ... }: +let + cfg = config.jconfig.gui.styling; + nerdFontSymbols = pkgs.nerdfonts.override { fonts = [ "NerdFontsSymbolsOnly" ]; }; + fallbackSymbols = { + name = "Symbols Nerd Font"; + package = nerdFontSymbols; + }; +in +{ + image = cfg.wallpaper; + base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-dark-hard.yaml"; + polarity = "dark"; + fonts.monospace.name = "JetBrains Mono"; + fonts.monospace.package = pkgs.jetbrains-mono; + fonts.sansSerif.name = "Noto Sans"; + fonts.sansSerif.package = pkgs.noto-fonts; + fonts.serif.name = "Noto Serif"; + fonts.serif.package = pkgs.noto-fonts; + fonts.fallbackFonts.monospace = [ fallbackSymbols ]; + fonts.fallbackFonts.sansSerif = [ fallbackSymbols ]; + fonts.fallbackFonts.serif = [ fallbackSymbols ]; + fonts.sizes.popups = 12; + targets.plymouth.logoAnimated = false; + targets.plymouth.logo = cfg.bootLogo; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c1def26 --- /dev/null +++ b/flake.lock @@ -0,0 +1,254 @@ +{ + "nodes": { + "base16": { + "inputs": { + "fromYaml": "fromYaml" + }, + "locked": { + "lastModified": 1689633990, + "narHash": "sha256-iwvQg2Vx0IIDWZaKo8Xmzxlv1YPHg+Kp/QSv8dRv0RY=", + "owner": "SenchoPens", + "repo": "base16.nix", + "rev": "dddf2e1c04845d43c89a8e9e37d574519649a404", + "type": "github" + }, + "original": { + "owner": "SenchoPens", + "repo": "base16.nix", + "type": "github" + } + }, + "base16-alacritty": { + "flake": false, + "locked": { + "lastModified": 1674275109, + "narHash": "sha256-Adwx9yP70I6mJrjjODOgZJjt4OPPe8gJu7UuBboXO4M=", + "owner": "aarowill", + "repo": "base16-alacritty", + "rev": "63d8ae5dfefe5db825dd4c699d0cdc2fc2c3eaf7", + "type": "github" + }, + "original": { + "owner": "aarowill", + "repo": "base16-alacritty", + "type": "github" + } + }, + "base16-fish": { + "flake": false, + "locked": { + "lastModified": 1622559957, + "narHash": "sha256-PebymhVYbL8trDVVXxCvZgc0S5VxI7I1Hv4RMSquTpA=", + "owner": "tomyun", + "repo": "base16-fish", + "rev": "2f6dd973a9075dabccd26f1cded09508180bf5fe", + "type": "github" + }, + "original": { + "owner": "tomyun", + "repo": "base16-fish", + "type": "github" + } + }, + "base16-foot": { + "flake": false, + "locked": { + "lastModified": 1696725948, + "narHash": "sha256-65bz2bUL/yzZ1c8/GQASnoiGwaF8DczlxJtzik1c0AU=", + "owner": "tinted-theming", + "repo": "base16-foot", + "rev": "eedbcfa30de0a4baa03e99f5e3ceb5535c2755ce", + "type": "github" + }, + "original": { + "owner": "tinted-theming", + "repo": "base16-foot", + "type": "github" + } + }, + "base16-helix": { + "flake": false, + "locked": { + "lastModified": 1696727917, + "narHash": "sha256-FVrbPk+NtMra0jtlC5oxyNchbm8FosmvXIatkRbYy1g=", + "owner": "tinted-theming", + "repo": "base16-helix", + "rev": "dbe1480d99fe80f08df7970e471fac24c05f2ddb", + "type": "github" + }, + "original": { + "owner": "tinted-theming", + "repo": "base16-helix", + "type": "github" + } + }, + "base16-kitty": { + "flake": false, + "locked": { + "lastModified": 1665001328, + "narHash": "sha256-aRaizTYPpuWEcvoYE9U+YRX+Wsc8+iG0guQJbvxEdJY=", + "owner": "kdrag0n", + "repo": "base16-kitty", + "rev": "06bb401fa9a0ffb84365905ffbb959ae5bf40805", + "type": "github" + }, + "original": { + "owner": "kdrag0n", + "repo": "base16-kitty", + "type": "github" + } + }, + "base16-tmux": { + "flake": false, + "locked": { + "lastModified": 1696725902, + "narHash": "sha256-wDPg5elZPcQpu7Df0lI5O8Jv4A3T6jUQIVg63KDU+3Q=", + "owner": "tinted-theming", + "repo": "base16-tmux", + "rev": "c02050bebb60dbb20cb433cd4d8ce668ecc11ba7", + "type": "github" + }, + "original": { + "owner": "tinted-theming", + "repo": "base16-tmux", + "type": "github" + } + }, + "base16-vim": { + "flake": false, + "locked": { + "lastModified": 1663659192, + "narHash": "sha256-uJvaYYDMXvoo0fhBZUhN8WBXeJ87SRgof6GEK2efFT0=", + "owner": "chriskempson", + "repo": "base16-vim", + "rev": "3be3cd82cd31acfcab9a41bad853d9c68d30478d", + "type": "github" + }, + "original": { + "owner": "chriskempson", + "repo": "base16-vim", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-schemas": { + "locked": { + "lastModified": 1697467827, + "narHash": "sha256-j8SR19V1SRysyJwpOBF4TLuAvAjF5t+gMiboN4gYQDU=", + "rev": "764932025c817d4e500a8d2a4d8c565563923d29", + "revCount": 29, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/DeterminateSystems/flake-schemas/0.1.2/018b3da8-4cc3-7fbb-8ff7-1588413c53e2/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/DeterminateSystems/flake-schemas/%2A.tar.gz" + } + }, + "fromYaml": { + "flake": false, + "locked": { + "lastModified": 1689549921, + "narHash": "sha256-iX0pk/uB019TdBGlaJEWvBCfydT6sRq+eDcGPifVsCM=", + "owner": "SenchoPens", + "repo": "fromYaml", + "rev": "11fbbbfb32e3289d3c631e0134a23854e7865c84", + "type": "github" + }, + "original": { + "owner": "SenchoPens", + "repo": "fromYaml", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1702537497, + "narHash": "sha256-br4Z7OFEHWN8oOnKf40BoS6QFt1EyVLqwaVGBG7/DT8=", + "rev": "7a88cdedbda35f808ed2f329a7a811e0511870f9", + "revCount": 3192, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/nix-community/home-manager/0.1.3192%2Brev-7a88cdedbda35f808ed2f329a7a811e0511870f9/018c6725-7e9b-7e8e-bb57-f493c0e4f7dc/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/nix-community/home-manager/0.1.%2A.tar.gz" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1705133751, + "narHash": "sha256-rCIsyE80jgiOU78gCWN3A0wE0tR2GI5nH6MlS+HaaSQ=", + "rev": "9b19f5e77dd906cb52dade0b7bd280339d2a1f3d", + "revCount": 571036, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.571036%2Brev-9b19f5e77dd906cb52dade0b7bd280339d2a1f3d/018d072b-1039-7cf8-a8f8-968a0abfe96e/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/NixOS/nixpkgs/0.1.%2A.tar.gz" + } + }, + "root": { + "inputs": { + "flake-schemas": "flake-schemas", + "home-manager": "home-manager", + "nixpkgs": "nixpkgs", + "stylix": "stylix" + } + }, + "stylix": { + "inputs": { + "base16": "base16", + "base16-alacritty": "base16-alacritty", + "base16-fish": "base16-fish", + "base16-foot": "base16-foot", + "base16-helix": "base16-helix", + "base16-kitty": "base16-kitty", + "base16-tmux": "base16-tmux", + "base16-vim": "base16-vim", + "flake-compat": "flake-compat", + "home-manager": [ + "home-manager" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1704308480, + "narHash": "sha256-88ICCdJyYYtsolRnPhI9IF+bhUIVUyhJ7nrKcKPgf6M=", + "rev": "9bc1900b6888efdda39c2e02c7c8666911b72608", + "revCount": 282, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/danth/stylix/0.1.282%2Brev-9bc1900b6888efdda39c2e02c7c8666911b72608/018cd0b4-3b01-7e09-9cce-fa1438aa91b9/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/danth/stylix/0.1.282.tar.gz" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..1677ccf --- /dev/null +++ b/flake.nix @@ -0,0 +1,36 @@ +# This flake was initially generated by fh, the CLI for FlakeHub (version 0.1.9) +{ + # A helpful description of your flake + description = "My NixOS configuration"; + + # Flake inputs + inputs.stylix.url = "https://flakehub.com/f/danth/stylix/0.1.282.tar.gz"; + inputs.stylix.inputs.nixpkgs.follows = "nixpkgs"; + inputs.stylix.inputs.home-manager.follows = "home-manager"; + inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz"; + inputs.home-manager.url = "https://flakehub.com/f/nix-community/home-manager/0.1.*.tar.gz"; + inputs.home-manager.inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-schemas.url = "https://flakehub.com/f/DeterminateSystems/flake-schemas/*.tar.gz"; + + # Flake outputs that other flakes can use + outputs = { flake-schemas, nixpkgs, stylix, ... }: + let + # Helpers for producing system-specific outputs + supportedSystems = [ "x86_64-linux" "aarch64-linux" ]; + forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { + pkgs = import nixpkgs { inherit system; }; + }); + in + { + # Schemas tell Nix about the structure of your flake's outputs + schemas = flake-schemas.schemas; + + # Nix files formatter (run `nix fmt`) + formatter = forEachSupportedSystem ({ pkgs }: pkgs.nixpkgs-fmt); + + nixosModules = rec { + default = nixosModule; + nixosModule = import ./configuration { inherit stylix; }; + }; + }; +}