├── configs ├── nixpkgs.nix ├── default.nix └── nix.nix ├── hosts ├── home-manager │ ├── penguin │ │ ├── system.nix │ │ └── default.nix │ ├── steamdeck │ │ ├── system.nix │ │ └── default.nix │ ├── home-linux │ │ ├── system.nix │ │ └── default.nix │ └── home-macos │ │ ├── system.nix │ │ └── default.nix ├── nix-darwin │ └── Sekai-MacBook-Pro │ │ └── default.nix └── nixos │ ├── zachune-nixos │ ├── disk-config.nix │ ├── hardware-configuration.nix │ └── default.nix │ ├── zatsune-nixos │ ├── disk-config.nix │ ├── hardware-configuration.nix │ └── default.nix │ ├── blackrockshooter-nixos │ ├── hardware-configuration.nix │ ├── disk-config.nix │ └── default.nix │ ├── sankyuu-nixos │ ├── hardware-configuration.nix │ ├── disk-config.nix │ └── default.nix │ └── hachune-nixos │ ├── default.nix │ └── hardware-configuration.nix ├── actions ├── utils.nix ├── validate-flakes.nix ├── update-flakes.nix ├── constants.nix ├── update-flakes-after.nix └── build-and-cache.nix ├── modules ├── shared │ ├── helpers │ │ ├── default.nix │ │ └── mk-home-module.nix │ ├── default.nix │ ├── meta.nix │ ├── theme │ │ ├── colors.json │ │ ├── get-base16-colors.sh │ │ ├── default.nix │ │ └── fonts.nix │ └── device.nix ├── home-manager │ ├── editor │ │ ├── emacs │ │ │ ├── doom-emacs │ │ │ │ ├── .gitignore │ │ │ │ ├── snippets │ │ │ │ │ └── nix-mode │ │ │ │ │ │ └── shell │ │ │ │ ├── packages.el │ │ │ │ └── autoload.el │ │ │ ├── disable_pgtk_display_x_warning.patch │ │ │ └── default.nix │ │ ├── default.nix │ │ ├── helix.nix │ │ └── idea.nix │ ├── dev │ │ ├── lua.nix │ │ ├── python.nix │ │ ├── go.nix │ │ ├── clojure.nix │ │ ├── asdf.nix │ │ ├── nix.nix │ │ ├── default.nix │ │ └── node.nix │ ├── cli │ │ ├── htop.nix │ │ ├── zellij.nix │ │ ├── jujutsu.nix │ │ ├── btop.nix │ │ ├── nixpkgs.nix │ │ ├── ssh │ │ │ ├── ssh-agent.zsh │ │ │ └── default.nix │ │ ├── yazi.nix │ │ ├── default.nix │ │ ├── irssi.nix │ │ └── tmux.nix │ ├── window-manager │ │ ├── wayland │ │ │ ├── kanshi │ │ │ │ ├── sankyuu-nixos.nix │ │ │ │ ├── blackrockshooter-nixos.nix │ │ │ │ └── default.nix │ │ │ ├── default.nix │ │ │ ├── fuzzel.nix │ │ │ ├── swayidle.nix │ │ │ └── swaylock.nix │ │ ├── theme │ │ │ ├── default.nix │ │ │ ├── gtk.nix │ │ │ └── qt.nix │ │ ├── gammastep.nix │ │ ├── x11 │ │ │ ├── picom.nix │ │ │ ├── wallpaper.nix │ │ │ ├── screen-locker.nix │ │ │ ├── default.nix │ │ │ ├── autorandr │ │ │ │ └── default.nix │ │ │ └── rofi.nix │ │ ├── dunst.nix │ │ └── default.nix │ ├── desktop │ │ ├── chromium.nix │ │ ├── default.nix │ │ ├── nixgl.nix │ │ ├── fonts │ │ │ ├── default.nix │ │ │ └── fontconfig.nix │ │ └── mpv │ │ │ └── motion-based-interpolation.vpy │ ├── default.nix │ ├── meta │ │ ├── diff.nix │ │ ├── restore-backups.nix │ │ └── default.nix │ ├── nix │ │ └── default.nix │ ├── darwin │ │ ├── default.nix │ │ └── homebrew.nix │ └── crostini.nix ├── nix-darwin │ ├── default.nix │ ├── cli.nix │ ├── home.nix │ ├── system.nix │ ├── nix │ │ ├── linux-builder.nix │ │ └── default.nix │ └── homebrew.nix └── nixos │ ├── default.nix │ ├── server │ ├── iperf3.nix │ ├── default.nix │ ├── watchdogd.nix │ ├── plex.nix │ ├── ssh.nix │ ├── tailscale.nix │ ├── samba.nix │ └── rtorrent.nix │ ├── system │ ├── networkd.nix │ ├── smart.nix │ ├── vm.nix │ ├── binfmt.nix │ ├── cli.nix │ ├── default.nix │ └── gpu.nix │ ├── games │ ├── ratbag.nix │ ├── osu.nix │ ├── steam.nix │ ├── default.nix │ ├── retroarch.nix │ └── jovian.nix │ ├── dev │ ├── ollama.nix │ ├── default.nix │ └── virtualisation │ │ ├── default.nix │ │ └── libvirt.nix │ ├── desktop │ ├── plymouth.nix │ ├── locale.nix │ ├── tailscale.nix │ ├── wireless.nix │ ├── fonts.nix │ ├── default.nix │ ├── kde.nix │ └── audio.nix │ ├── nix │ ├── diff.nix │ ├── remote-builders.nix │ └── default.nix │ ├── home.nix │ ├── window-manager │ ├── default.nix │ ├── greetd.nix │ ├── wayland.nix │ └── xserver.nix │ └── laptop │ ├── default.nix │ └── tlp.nix ├── .gitignore ├── lib ├── default.nix ├── attrsets.nix └── flake-helpers.nix ├── shell.nix ├── default.nix ├── packages ├── run-bg-alias │ └── default.nix ├── nix-whereis │ └── default.nix ├── wallpapers │ ├── mkWallpaperImgur.nix │ └── default.nix └── nix-cleanup │ └── default.nix ├── .github └── workflows │ ├── validate-flakes.yml │ ├── update-flakes.yml │ └── update-flakes-after.yml ├── templates └── new-host │ └── hosts │ └── nixos │ └── new-host │ └── default.nix ├── LICENSE ├── docs └── non-nixos.md ├── overlays └── default.nix └── treefmt.nix /configs/nixpkgs.nix: -------------------------------------------------------------------------------- 1 | { 2 | allowUnfree = true; 3 | } 4 | -------------------------------------------------------------------------------- /hosts/home-manager/penguin/system.nix: -------------------------------------------------------------------------------- 1 | "aarch64-linux" 2 | -------------------------------------------------------------------------------- /hosts/home-manager/steamdeck/system.nix: -------------------------------------------------------------------------------- 1 | "x86_64-linux" 2 | -------------------------------------------------------------------------------- /hosts/home-manager/home-linux/system.nix: -------------------------------------------------------------------------------- 1 | "x86_64-linux" 2 | -------------------------------------------------------------------------------- /hosts/home-manager/home-macos/system.nix: -------------------------------------------------------------------------------- 1 | "aarch64-darwin" 2 | -------------------------------------------------------------------------------- /actions/utils.nix: -------------------------------------------------------------------------------- 1 | { 2 | escapeGhVar = var: "\${{ ${var} }}"; 3 | } 4 | -------------------------------------------------------------------------------- /modules/shared/helpers/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | mkHomeModule = import ./mk-home-module.nix; 3 | } 4 | -------------------------------------------------------------------------------- /configs/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | nix = import ./nix.nix; 3 | nixpkgs = import ./nixpkgs.nix; 4 | } 5 | -------------------------------------------------------------------------------- /modules/home-manager/editor/emacs/doom-emacs/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore local configuration file 2 | local.el 3 | -------------------------------------------------------------------------------- /hosts/home-manager/home-linux/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | home.stateVersion = "24.05"; 3 | 4 | targets.genericLinux.enable = true; 5 | } 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | result 2 | result-* 3 | *.qcow2 4 | .direnv/ 5 | # Looks like a temporary file, but not sure 6 | doom-emacs/flycheck_config.el 7 | -------------------------------------------------------------------------------- /modules/shared/default.nix: -------------------------------------------------------------------------------- 1 | { ... }: 2 | 3 | { 4 | imports = [ 5 | ./device.nix 6 | ./meta.nix 7 | ./theme 8 | ]; 9 | } 10 | -------------------------------------------------------------------------------- /lib/default.nix: -------------------------------------------------------------------------------- 1 | { nixpkgs, ... }@inputs: 2 | 3 | nixpkgs.lib.mergeAttrsList [ 4 | (import ./attrsets.nix inputs) 5 | (import ./flake-helpers.nix inputs) 6 | ] 7 | -------------------------------------------------------------------------------- /configs/nix.nix: -------------------------------------------------------------------------------- 1 | (import ../flake.nix).nixConfig 2 | // { 3 | experimental-features = [ 4 | "nix-command" 5 | "flakes" 6 | ]; 7 | 8 | max-jobs = "auto"; 9 | } 10 | -------------------------------------------------------------------------------- /hosts/home-manager/home-macos/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | home = rec { 3 | username = "thiagoko"; 4 | homeDirectory = "/Users/${username}"; 5 | stateVersion = "24.05"; 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /modules/nix-darwin/default.nix: -------------------------------------------------------------------------------- 1 | { flake, ... }: 2 | 3 | { 4 | imports = [ 5 | flake.outputs.internal.sharedModules.default 6 | ./cli.nix 7 | ./home.nix 8 | ./homebrew.nix 9 | ./nix 10 | ./system.nix 11 | ]; 12 | } 13 | -------------------------------------------------------------------------------- /modules/home-manager/editor/default.nix: -------------------------------------------------------------------------------- 1 | { lib, ... }: 2 | 3 | { 4 | imports = [ 5 | ./emacs 6 | ./helix.nix 7 | ./idea.nix 8 | ./neovim.nix 9 | ]; 10 | 11 | options.home-manager.editor.enable = lib.mkEnableOption "editor config" // { 12 | default = true; 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /shell.nix: -------------------------------------------------------------------------------- 1 | let 2 | lock = builtins.fromJSON (builtins.readFile ./flake.lock); 3 | inherit (lock.nodes.flake-compat.locked) rev narHash; 4 | in 5 | (import (fetchTarball { 6 | url = "https://github.com/edolstra/flake-compat/archive/${rev}.tar.gz"; 7 | sha256 = narHash; 8 | }) { src = ./.; }).shellNix 9 | -------------------------------------------------------------------------------- /default.nix: -------------------------------------------------------------------------------- 1 | let 2 | lock = builtins.fromJSON (builtins.readFile ./flake.lock); 3 | inherit (lock.nodes.flake-compat.locked) rev narHash; 4 | in 5 | (import (fetchTarball { 6 | url = "https://github.com/edolstra/flake-compat/archive/${rev}.tar.gz"; 7 | sha256 = narHash; 8 | }) { src = ./.; }).defaultNix 9 | -------------------------------------------------------------------------------- /modules/nixos/default.nix: -------------------------------------------------------------------------------- 1 | { flake, ... }: 2 | 3 | { 4 | imports = [ 5 | flake.outputs.internal.sharedModules.default 6 | ./desktop 7 | ./dev 8 | ./games 9 | ./home.nix 10 | ./laptop 11 | ./nix 12 | ./server 13 | ./system 14 | ./window-manager 15 | ]; 16 | } 17 | -------------------------------------------------------------------------------- /modules/nixos/server/iperf3.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | { 4 | options.nixos.server.iperf3.enable = lib.mkEnableOption "IPerf3 config"; 5 | 6 | config = lib.mkIf config.nixos.server.iperf3.enable { 7 | services.iperf3 = { 8 | enable = true; 9 | openFirewall = true; 10 | }; 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /modules/home-manager/editor/emacs/doom-emacs/snippets/nix-mode/shell: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: shell.nix boilerplate 3 | # key: mkShell 4 | # uuid: mkShell 5 | # condition: (eq 1 (line-number-at-pos)) 6 | # -- 7 | { pkgs ? import {}, ... }: 8 | 9 | pkgs.mkShell { 10 | buildInputs = with pkgs; [ ${1:pkgs} ]; 11 | } 12 | -------------------------------------------------------------------------------- /hosts/home-manager/penguin/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | home.stateVersion = "24.05"; 3 | 4 | targets.genericLinux.nixGL = { 5 | defaultWrapper = "mesa"; 6 | installScripts = [ "mesa" ]; 7 | }; 8 | 9 | home-manager = { 10 | crostini.enable = true; 11 | cli.git.gui.enable = true; 12 | desktop.mpv.enable = true; 13 | dev.enable = true; 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /modules/home-manager/dev/lua.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | { 9 | options.home-manager.dev.lua.enable = lib.mkEnableOption "Lua config" // { 10 | default = config.home-manager.dev.enable; 11 | }; 12 | 13 | config = lib.mkIf config.home-manager.dev.lua.enable { 14 | home.packages = with pkgs; [ 15 | lua 16 | lua-language-server 17 | ]; 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /modules/shared/meta.nix: -------------------------------------------------------------------------------- 1 | { lib, ... }: 2 | 3 | { 4 | options.meta = { 5 | fullname = lib.mkOption { 6 | description = "Main user full name."; 7 | type = lib.types.str; 8 | default = "Thiago Kenji Okada"; 9 | }; 10 | email = lib.mkOption { 11 | description = "Main e-mail."; 12 | type = lib.types.str; 13 | default = "thiagokokada@gmail.com"; 14 | }; 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /modules/home-manager/cli/htop.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | lib, 5 | ... 6 | }: 7 | 8 | { 9 | options.home-manager.cli.htop.enable = lib.mkEnableOption "htop config" // { 10 | default = config.home-manager.cli.enable; 11 | }; 12 | 13 | config = lib.mkIf config.home-manager.cli.htop.enable { 14 | programs.htop = { 15 | enable = true; 16 | package = pkgs.htop-vim; 17 | }; 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /hosts/home-manager/steamdeck/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | home = rec { 3 | username = "deck"; 4 | homeDirectory = "/home/${username}"; 5 | stateVersion = "25.05"; 6 | }; 7 | 8 | targets.genericLinux.nixGL = { 9 | defaultWrapper = "mesa"; 10 | installScripts = [ "mesa" ]; 11 | }; 12 | 13 | home-manager = { 14 | cli.git.gui.enable = true; 15 | dev.enable = true; 16 | }; 17 | 18 | targets.genericLinux.enable = true; 19 | } 20 | -------------------------------------------------------------------------------- /modules/home-manager/dev/python.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | lib, 5 | ... 6 | }: 7 | 8 | { 9 | options.home-manager.dev.python.enable = lib.mkEnableOption "Python config" // { 10 | default = config.home-manager.dev.enable; 11 | }; 12 | 13 | config = lib.mkIf config.home-manager.dev.python.enable { 14 | home.packages = with pkgs; [ 15 | pyright 16 | python3 17 | ruff 18 | uv 19 | ]; 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /modules/nixos/system/networkd.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | let 3 | cfg = config.nixos.system.networkd; 4 | in 5 | { 6 | options.nixos.system.networkd = { 7 | enable = lib.mkEnableOption "systemd-networkd config"; 8 | }; 9 | 10 | config = lib.mkIf cfg.enable { 11 | services.resolved = { 12 | enable = true; 13 | # Can make DNS lookups really slow 14 | dnssec = "false"; 15 | }; 16 | networking.useNetworkd = true; 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /modules/nix-darwin/cli.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | let 4 | cfg = config.nix-darwin.cli; 5 | in 6 | { 7 | options.nix-darwin.cli.enable = lib.mkEnableOption "CLI config" // { 8 | default = true; 9 | }; 10 | 11 | config = lib.mkIf cfg.enable { 12 | programs.zsh = { 13 | # Needed otherwise ZSH has no Nix environment setup 14 | enable = true; 15 | # Managed by zim-completion 16 | enableCompletion = false; 17 | }; 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /modules/shared/theme/colors.json: -------------------------------------------------------------------------------- 1 | { 2 | "base00": "#1d1f21", 3 | "base01": "#282a2e", 4 | "base02": "#373b41", 5 | "base03": "#969896", 6 | "base04": "#b4b7b4", 7 | "base05": "#c5c8c6", 8 | "base06": "#e0e0e0", 9 | "base07": "#ffffff", 10 | "base08": "#cc6666", 11 | "base09": "#de935f", 12 | "base0A": "#f0c674", 13 | "base0B": "#b5bd68", 14 | "base0C": "#8abeb7", 15 | "base0D": "#81a2be", 16 | "base0E": "#b294bb", 17 | "base0F": "#a3685a" 18 | } 19 | -------------------------------------------------------------------------------- /modules/home-manager/editor/emacs/doom-emacs/packages.el: -------------------------------------------------------------------------------- 1 | ;; -*- no-byte-compile: t; -*- 2 | ;;; ~/.doom.d/packages.el 3 | 4 | ;;; Examples: 5 | ;; (package! some-package) 6 | ;; (package! another-package :recipe (:fetcher github :repo "username/repo")) 7 | ;; (package! builtin-package :disable t) 8 | (package! evil-escape :disable t) 9 | (package! flycheck-clj-kondo :disable t) 10 | (package! lispyville) 11 | (package! lsp-ui :disable t) 12 | (package! sort-words) 13 | (package! uuidgen) 14 | -------------------------------------------------------------------------------- /modules/nixos/system/smart.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | { 9 | options.nixos.system.smart = { 10 | enable = lib.mkEnableOption "SMART config" // { 11 | default = config.nixos.system.enable; 12 | }; 13 | }; 14 | 15 | config = lib.mkIf config.nixos.system.smart.enable { 16 | environment.systemPackages = with pkgs; [ 17 | hdparm 18 | smartmontools 19 | ]; 20 | 21 | services.smartd.enable = true; 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /modules/nixos/games/ratbag.nix: -------------------------------------------------------------------------------- 1 | { 2 | pkgs, 3 | lib, 4 | config, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.nixos.games.ratbag; 10 | in 11 | { 12 | options.nixos.games.ratbag.enable = 13 | lib.mkEnableOption "Ratbag/Piper (e.g. Logitech devices) config"; 14 | 15 | config = lib.mkIf cfg.enable { 16 | environment.systemPackages = with pkgs; [ piper ]; 17 | 18 | # Enable ratbagd (i.e.: piper) for Logitech devices 19 | services.ratbagd.enable = true; 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /modules/nix-darwin/home.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | flake, 4 | lib, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.nix-darwin.home; 10 | inherit (config.nix-darwin.home) username; 11 | in 12 | { 13 | imports = [ 14 | (flake.outputs.internal.sharedModules.helpers.mkHomeModule "nix-darwin") 15 | flake.inputs.home-manager.darwinModules.home-manager 16 | ]; 17 | 18 | config = lib.mkIf cfg.enable { 19 | users.users.${username}.home = lib.mkDefault "/Users/${username}"; 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /modules/nixos/games/osu.nix: -------------------------------------------------------------------------------- 1 | { 2 | pkgs, 3 | lib, 4 | config, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.nixos.games.osu; 10 | in 11 | { 12 | options.nixos.games.osu.enable = lib.mkEnableOption "osu! config"; 13 | 14 | config = lib.mkIf cfg.enable { 15 | nixos.desktop.audio.lowLatency.enable = lib.mkDefault true; 16 | 17 | environment.systemPackages = with pkgs; [ osu-lazer ]; 18 | 19 | # Enable opentabletdriver 20 | hardware.opentabletdriver.enable = true; 21 | }; 22 | } 23 | -------------------------------------------------------------------------------- /actions/validate-flakes.nix: -------------------------------------------------------------------------------- 1 | let 2 | steps = import ./steps.nix; 3 | constants = import ./constants.nix; 4 | in 5 | with constants; 6 | { 7 | name = "validate-flakes"; 8 | on = [ 9 | "push" 10 | "workflow_dispatch" 11 | ]; 12 | inherit (steps) concurrency; 13 | 14 | jobs = { 15 | build-x86_64-linux = { 16 | inherit (ubuntu) runs-on; 17 | steps = 18 | with steps; 19 | withSharedSteps [ 20 | validateFlakesStep 21 | ]; 22 | }; 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /modules/home-manager/cli/zellij.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | { 4 | options.home-manager.cli.zellij.enable = lib.mkEnableOption "Zellij config" // { 5 | default = config.home-manager.cli.enable; 6 | }; 7 | 8 | config = lib.mkIf config.home-manager.cli.zellij.enable { 9 | programs.zellij = { 10 | enable = true; 11 | settings = { 12 | default_mode = "normal"; 13 | show_startup_tips = false; 14 | show_release_notes = false; 15 | }; 16 | }; 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /packages/run-bg-alias/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | writeShellApplication, 3 | coreutils, 4 | daemonize, 5 | name, 6 | command, 7 | }: 8 | 9 | writeShellApplication { 10 | inherit name; 11 | 12 | runtimeInputs = [ 13 | coreutils 14 | daemonize 15 | ]; 16 | 17 | text = # bash 18 | '' 19 | cmd="$(basename ${command})" 20 | tmpdir="$(mktemp "run-bg-$cmd.XXXXXX" -d --tmpdir="''${TMPDIR:-}")" 21 | daemonize -o "$tmpdir/stdout" -e "$tmpdir/stderr" -c "$PWD" "${command}" "$@" 22 | ''; 23 | } 24 | -------------------------------------------------------------------------------- /modules/shared/theme/get-base16-colors.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env nix-shell 2 | #! nix-shell -i bash -p curl yq jq 3 | # shellcheck shell=bash 4 | 5 | set -euo pipefail 6 | 7 | # Takes a raw link to the base16 YAML file and converts it to JSON 8 | # Example: 9 | # $ ./get-base16-colors.sh https://raw.githubusercontent.com/chriskempson/base16-tomorrow-scheme/master/tomorrow-night.yaml | tee ./colors.json 10 | 11 | curl -s "$1" | 12 | yq 'to_entries[] | select(.key | startswith("base")) | .value |= "#" + .' | 13 | jq -s 'from_entries' 14 | -------------------------------------------------------------------------------- /modules/home-manager/editor/emacs/doom-emacs/autoload.el: -------------------------------------------------------------------------------- 1 | ;;; ~/.doom.d/autoload.el -*- lexical-binding: t; -*- 2 | 3 | ;;;###autoload 4 | (defun user/screenshot-svg () 5 | "Save a screenshot of the current frame as an SVG image. 6 | Saves to a temp file and puts the filename in the kill ring." 7 | (interactive) 8 | (let* ((filename (make-temp-file "Emacs" nil ".svg")) 9 | (data (x-export-frames nil 'svg))) 10 | (with-temp-file filename 11 | (insert data)) 12 | (kill-new filename) 13 | (message filename))) 14 | -------------------------------------------------------------------------------- /modules/home-manager/editor/emacs/disable_pgtk_display_x_warning.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/pgtkterm.c b/src/pgtkterm.c 2 | index c00e135..7094f9c 100644 3 | --- a/src/pgtkterm.c 4 | +++ b/src/pgtkterm.c 5 | @@ -6792,7 +6792,7 @@ pgtk_term_init (Lisp_Object display_name, char *resource_name) 6 | 7 | /* If the PGTK port is being used under X, complain very loudly, as 8 | that isn't supported. */ 9 | - pgtk_display_x_warning (dpy); 10 | + /* pgtk_display_x_warning (dpy); */ 11 | 12 | dpyinfo = xzalloc (sizeof *dpyinfo); 13 | pgtk_initialize_display_info (dpyinfo); 14 | -------------------------------------------------------------------------------- /packages/nix-whereis/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | writeShellApplication, 3 | coreutils, 4 | which, 5 | }: 6 | 7 | writeShellApplication { 8 | name = "nix-whereis"; 9 | 10 | text = '' 11 | readonly program_name="''${1:-}" 12 | 13 | if [[ -z "$program_name" ]]; then 14 | cat < 16 | 17 | Get where in /nix/store a program is located. 18 | EOF 19 | exit 1 20 | fi 21 | 22 | readlink -f "$(which "$program_name")" 23 | ''; 24 | 25 | runtimeInputs = [ 26 | coreutils 27 | which 28 | ]; 29 | } 30 | -------------------------------------------------------------------------------- /modules/home-manager/window-manager/wayland/kanshi/sankyuu-nixos.nix: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | profile.name = "undocked"; 4 | profile.outputs = [ 5 | { 6 | criteria = "eDP-1"; 7 | status = "enable"; 8 | } 9 | ]; 10 | } 11 | { 12 | profile.name = "docked"; 13 | profile.outputs = [ 14 | { 15 | criteria = "Dell Inc. DELL S3423DWC 10CWNH3"; 16 | mode = "3440x1440@99.98"; 17 | status = "enable"; 18 | } 19 | { 20 | criteria = "eDP-1"; 21 | status = "disable"; 22 | } 23 | ]; 24 | } 25 | ] 26 | -------------------------------------------------------------------------------- /modules/home-manager/cli/jujutsu.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | let 4 | cfg = config.home-manager.cli.jujutsu; 5 | in 6 | { 7 | options.home-manager.cli.jujutsu = { 8 | enable = lib.mkEnableOption "Jujutsu config" // { 9 | default = config.home-manager.cli.enable; 10 | }; 11 | }; 12 | 13 | config = lib.mkIf cfg.enable { 14 | programs.jujutsu = { 15 | enable = true; 16 | settings = { 17 | ui.editor = "nvim"; 18 | user = { 19 | name = config.meta.fullname; 20 | inherit (config.meta) email; 21 | }; 22 | }; 23 | }; 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /modules/nixos/dev/ollama.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | ... 5 | }: 6 | 7 | { 8 | options.nixos.dev.ollama.enable = lib.mkEnableOption "Ollama config" // { 9 | default = config.nixos.dev.enable; 10 | }; 11 | 12 | config = lib.mkIf config.nixos.dev.ollama.enable { 13 | services = { 14 | ollama = { 15 | enable = true; 16 | # Define additional models in hosts, since depending on the host vRAM 17 | # we can run bigger or smaller models 18 | # https://ollama.com/library 19 | loadModels = [ 20 | "llama3.2:3b" 21 | ]; 22 | }; 23 | }; 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /modules/home-manager/dev/go.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | let 9 | GOPATH = "${config.home.homeDirectory}/.go"; 10 | GOBIN = "${GOPATH}/bin"; 11 | in 12 | { 13 | options.home-manager.dev.go.enable = lib.mkEnableOption "Go config" // { 14 | default = config.home-manager.dev.enable; 15 | }; 16 | 17 | config = lib.mkIf config.home-manager.dev.go.enable { 18 | programs.go = { 19 | enable = true; 20 | env = { inherit GOBIN GOPATH; }; 21 | }; 22 | 23 | home = { 24 | packages = with pkgs; [ gopls ]; 25 | sessionPath = [ GOBIN ]; 26 | }; 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /modules/home-manager/desktop/chromium.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | lib, 5 | ... 6 | }: 7 | 8 | { 9 | options.home-manager.desktop.chromium.enable = lib.mkEnableOption "Chromium config" // { 10 | default = config.home-manager.desktop.enable; 11 | }; 12 | 13 | config = lib.mkIf config.home-manager.desktop.chromium.enable { 14 | programs.chromium = { 15 | enable = true; 16 | package = pkgs.google-chrome; 17 | extensions = [ 18 | { id = "cjpalhdlnbpafiamejdnhcphjbkeiagm"; } # ublock origin 19 | { id = "hfjbmagddngcpeloejdejnfgbamkjaeg"; } # vimium-c 20 | ]; 21 | }; 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /modules/home-manager/dev/clojure.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | lib, 5 | ... 6 | }: 7 | 8 | { 9 | options.home-manager.dev.clojure.enable = lib.mkEnableOption "Clojure config" // { 10 | default = config.home-manager.dev.enable; 11 | }; 12 | 13 | config = lib.mkIf config.home-manager.dev.clojure.enable { 14 | home.packages = with pkgs; [ 15 | (babashka.override { withRlwrap = true; }) 16 | clojure 17 | clojure-lsp 18 | (leiningen.override { inherit (clojure) jdk; }) 19 | ]; 20 | 21 | programs.java = { 22 | enable = true; 23 | package = pkgs.clojure.jdk; 24 | }; 25 | }; 26 | } 27 | -------------------------------------------------------------------------------- /modules/home-manager/cli/btop.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | { 9 | options.home-manager.cli.btop.enable = lib.mkEnableOption "btop config" // { 10 | default = config.home-manager.cli.enable; 11 | }; 12 | 13 | config = lib.mkIf config.home-manager.cli.btop.enable { 14 | programs.btop = { 15 | enable = true; 16 | # https://github.com/aristocratos/btop 17 | settings = { 18 | color_theme = "${pkgs.btop}/share/btop/themes/dracula.theme"; 19 | vim_keys = true; 20 | graph_symbol = "block"; 21 | proc_gradient = false; 22 | }; 23 | }; 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /modules/nixos/desktop/plymouth.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | { 4 | options.nixos.desktop.plymouth.enable = lib.mkEnableOption "Plymouth config" // { 5 | default = config.nixos.desktop.enable; 6 | }; 7 | 8 | config = lib.mkIf config.nixos.desktop.plymouth.enable { 9 | boot = { 10 | plymouth.enable = true; 11 | 12 | # Enable "Silent boot" 13 | consoleLogLevel = 3; 14 | initrd.verbose = false; 15 | kernelParams = [ 16 | "quiet" 17 | "splash" 18 | "boot.shell_on_fail" 19 | "udev.log_priority=3" 20 | "rd.systemd.show_status=auto" 21 | ]; 22 | }; 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /modules/home-manager/window-manager/wayland/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | { 9 | imports = [ 10 | ./fuzzel.nix 11 | ./kanshi 12 | ./sway.nix 13 | ./swayidle.nix 14 | ./swaylock.nix 15 | ./waybar.nix 16 | ]; 17 | 18 | options.home-manager.window-manager.wayland.enable = lib.mkEnableOption "Wayland config" // { 19 | default = config.home-manager.window-manager.enable; 20 | }; 21 | 22 | config = lib.mkIf config.home-manager.window-manager.wayland.enable { 23 | home.packages = with pkgs; [ 24 | waypipe 25 | wdisplays 26 | wl-clipboard 27 | ]; 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /modules/home-manager/window-manager/wayland/kanshi/blackrockshooter-nixos.nix: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | profile.name = "tv-only"; 4 | profile.outputs = [ 5 | { 6 | criteria = "LG Electronics LG TV SSCR2 0x01010101"; 7 | status = "enable"; 8 | } 9 | ]; 10 | } 11 | { 12 | profile.name = "monitor-only"; 13 | profile.outputs = [ 14 | { 15 | criteria = "Dell Inc. DELL S3423DWC 10CWNH3"; 16 | mode = "3440x1440@99.98"; 17 | status = "enable"; 18 | } 19 | { 20 | criteria = "LG Electronics LG TV SSCR2 0x01010101"; 21 | status = "disable"; 22 | } 23 | ]; 24 | } 25 | ] 26 | -------------------------------------------------------------------------------- /modules/home-manager/desktop/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.home-manager.window-manager; 10 | in 11 | { 12 | imports = [ 13 | ./chromium.nix 14 | ./firefox.nix 15 | ./fonts 16 | ./kitty.nix 17 | ./mpv 18 | ./nixgl.nix 19 | ]; 20 | 21 | options.home-manager.desktop = { 22 | enable = lib.mkEnableOption "desktop config"; 23 | }; 24 | 25 | config = lib.mkIf cfg.enable { 26 | home.packages = with pkgs; [ 27 | android-file-transfer 28 | audacious 29 | libreoffice-fresh 30 | (mcomix.override { unrarSupport = true; }) 31 | ]; 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /modules/home-manager/default.nix: -------------------------------------------------------------------------------- 1 | { flake, lib, ... }: 2 | 3 | { 4 | imports = [ 5 | flake.outputs.internal.sharedModules.default 6 | ./cli 7 | ./crostini.nix 8 | ./darwin 9 | ./desktop 10 | ./dev 11 | ./editor 12 | ./meta 13 | ./nix 14 | ./window-manager 15 | ]; 16 | 17 | options.home-manager = { 18 | hostName = lib.mkOption { 19 | description = "The hostname of the machine."; 20 | type = lib.types.str; 21 | default = "generic"; 22 | }; 23 | }; 24 | 25 | config = { 26 | home = { 27 | username = lib.mkOptionDefault "thiagoko"; 28 | homeDirectory = lib.mkOptionDefault "/home/thiagoko"; 29 | }; 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /modules/home-manager/window-manager/theme/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | lib, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.home-manager.window-manager.theme; 10 | in 11 | { 12 | imports = [ 13 | ./gtk.nix 14 | ./qt.nix 15 | ]; 16 | 17 | options.home-manager.window-manager.theme = { 18 | enable = lib.mkEnableOption "theme config" // { 19 | default = config.home-manager.window-manager.enable; 20 | }; 21 | }; 22 | 23 | config = lib.mkIf cfg.enable { 24 | home.pointerCursor = { 25 | package = pkgs.nordzy-cursor-theme; 26 | name = "Nordzy-cursors"; 27 | size = 32; 28 | x11.enable = true; 29 | gtk.enable = true; 30 | }; 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /modules/nix-darwin/system.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | let 4 | cfg = config.nix-darwin.system; 5 | in 6 | { 7 | options.nix-darwin.system.enable = lib.mkEnableOption "system config" // { 8 | default = true; 9 | }; 10 | 11 | config = lib.mkIf cfg.enable { 12 | environment = { 13 | # https://github.com/nix-darwin/nix-darwin/issues/1507 14 | etc."zshenv".text = 15 | lib.mkBefore 16 | # bash 17 | '' 18 | export USER="$(whoami)" 19 | ''; 20 | # To get zsh completion for system packages 21 | pathsToLink = [ "/share/zsh" ]; 22 | }; 23 | 24 | # Enable sudo via TouchID 25 | security.pam.services.sudo_local.touchIdAuth = true; 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /modules/nixos/nix/diff.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.nixos.nix.diff; 10 | in 11 | { 12 | options.nixos.nix.diff.enable = lib.mkEnableOption "diff configuration on activation" // { 13 | default = config.nixos.nix.enable; 14 | }; 15 | 16 | config = lib.mkIf cfg.enable { 17 | system.activationScripts.diff = 18 | # bash 19 | '' 20 | export PATH="${lib.makeBinPath [ config.nix.package ]}:$PATH" 21 | if [[ -e '/run/current-system' ]]; then 22 | echo "showing changes compared to /run/current-system..." 23 | ${lib.getExe pkgs.nvd} diff '/run/current-system' "$systemConfig" || true 24 | fi 25 | ''; 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /modules/nixos/server/default.nix: -------------------------------------------------------------------------------- 1 | { lib, config, ... }: 2 | { 3 | options.nixos.server.enable = lib.mkEnableOption "server config" // { 4 | default = config.device.type == "server"; 5 | }; 6 | 7 | imports = [ 8 | ./duckdns-updater.nix 9 | ./iperf3.nix 10 | ./plex.nix 11 | ./rtorrent.nix 12 | ./samba.nix 13 | ./ssh.nix 14 | ./tailscale.nix 15 | ./watchdogd.nix 16 | ]; 17 | 18 | config = lib.mkIf config.nixos.server.enable { 19 | system.autoUpgrade = { 20 | allowReboot = lib.mkDefault true; 21 | rebootWindow = { 22 | lower = lib.mkDefault "02:30"; 23 | upper = lib.mkDefault "05:30"; 24 | }; 25 | randomizedDelaySec = lib.mkDefault "30min"; 26 | }; 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /modules/home-manager/desktop/nixgl.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | flake, 6 | ... 7 | }: 8 | 9 | let 10 | cfg = config.home-manager.desktop.nixgl; 11 | in 12 | { 13 | options.home-manager.desktop.nixgl = { 14 | enable = lib.mkEnableOption "nixGL config" // { 15 | default = config.targets.genericLinux.enable; 16 | }; 17 | }; 18 | 19 | config = lib.mkIf cfg.enable { 20 | targets.genericLinux.nixGL = { 21 | inherit (flake.inputs.nixgl) packages; 22 | }; 23 | 24 | programs = with config.lib.nixGL; { 25 | firefox.package = lib.mkForce (wrap pkgs.firefox); 26 | kitty.package = lib.mkForce (wrap pkgs.kitty); 27 | mpv.package = lib.mkForce (wrap pkgs.mpv); 28 | }; 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /modules/home-manager/window-manager/gammastep.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | { 4 | options.home-manager.window-manager.gammastep.enable = lib.mkEnableOption "gammastep config" // { 5 | default = config.home-manager.window-manager.enable; 6 | }; 7 | 8 | config = lib.mkIf config.home-manager.window-manager.gammastep.enable { 9 | services.gammastep = { 10 | enable = config.device.type != "vm"; 11 | tray = true; 12 | dawnTime = "6:30-7:30"; 13 | duskTime = "18:30-19:30"; 14 | temperature = { 15 | day = 5700; 16 | night = 3700; 17 | }; 18 | settings = { 19 | general = { 20 | gamma = 0.8; 21 | fade = 1; 22 | }; 23 | }; 24 | }; 25 | }; 26 | } 27 | -------------------------------------------------------------------------------- /modules/nixos/dev/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | ... 5 | }: 6 | 7 | let 8 | inherit (config.nixos.home) username; 9 | in 10 | { 11 | imports = [ 12 | ./ollama.nix 13 | ./virtualisation 14 | ]; 15 | 16 | options.nixos.dev.enable = lib.mkEnableOption "developer config" // { 17 | default = builtins.any (x: config.device.type == x) [ 18 | "desktop" 19 | "laptop" 20 | "steam-machine" 21 | ]; 22 | }; 23 | 24 | config = lib.mkIf config.nixos.dev.enable { 25 | nixos.home.extraModules = { 26 | home-manager.dev.enable = true; 27 | }; 28 | 29 | programs.adb.enable = true; 30 | 31 | # Added user to groups 32 | users.users.${username}.extraGroups = [ "adbusers" ]; 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /modules/home-manager/meta/diff.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.home-manager.meta.diff; 10 | in 11 | { 12 | options.home-manager.meta.diff.enable = lib.mkEnableOption "diff configuration on activation" // { 13 | default = config.home-manager.meta.enable; 14 | }; 15 | 16 | config = lib.mkIf cfg.enable { 17 | home.activation.diff = 18 | lib.hm.dag.entryAnywhere 19 | # bash 20 | '' 21 | export PATH="${lib.makeBinPath [ config.nix.package ]}:$PATH" 22 | if [[ -n "''${oldGenPath:-}" ]] && [[ -n "''${newGenPath:-}" ]]; then 23 | ${lib.getExe pkgs.nvd} diff "$oldGenPath" "$newGenPath" || true 24 | fi 25 | ''; 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /modules/nixos/desktop/locale.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | { 4 | options.nixos.desktop.locale.enable = lib.mkEnableOption "locale config" // { 5 | default = config.nixos.desktop.enable; 6 | }; 7 | 8 | config = lib.mkIf config.nixos.desktop.locale.enable { 9 | # Select internationalisation properties. 10 | i18n = { 11 | defaultLocale = lib.mkDefault "en_IE.UTF-8"; 12 | extraLocaleSettings = { 13 | LC_CTYPE = lib.mkDefault "pt_BR.UTF-8"; # Fix ç in us-intl. 14 | }; 15 | inputMethod = { 16 | enable = true; 17 | type = "fcitx5"; 18 | fcitx5.waylandFrontend = true; 19 | }; 20 | }; 21 | 22 | # Set your time zone. 23 | time.timeZone = lib.mkDefault "America/Sao_Paulo"; 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /modules/nixos/system/vm.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | let 4 | cfg = config.nixos.system.vm; 5 | in 6 | { 7 | options.nixos.system.vm = { 8 | enable = lib.mkEnableOption "Virtual Machine config" // { 9 | default = config.nixos.system.enable; 10 | }; 11 | vmConfig = lib.mkOption { 12 | type = lib.types.attrs; 13 | description = "Virtualisation options."; 14 | default = { 15 | memorySize = 4096; 16 | cores = 4; 17 | }; 18 | }; 19 | }; 20 | 21 | config = lib.mkIf cfg.enable { 22 | virtualisation = { 23 | vmVariant = { 24 | virtualisation = cfg.vmConfig; 25 | }; 26 | vmVariantWithBootLoader = { 27 | virtualisation = cfg.vmConfig; 28 | }; 29 | }; 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /actions/update-flakes.nix: -------------------------------------------------------------------------------- 1 | let 2 | steps = import ./steps.nix; 3 | constants = import ./constants.nix; 4 | in 5 | with constants; 6 | { 7 | name = "update-flakes"; 8 | on = { 9 | schedule = [ { cron = "40 4 * * 0,2,4,6"; } ]; 10 | workflow_dispatch = null; 11 | }; 12 | inherit (steps) concurrency; 13 | 14 | jobs = { 15 | update-flakes-x86_64-linux = { 16 | inherit (ubuntu) runs-on; 17 | steps = 18 | with steps; 19 | withSharedSteps [ 20 | freeDiskSpaceStep 21 | updateFlakeLockStep 22 | (buildHomeManagerConfigurations { inherit (home-manager.x86_64-linux) hostNames; }) 23 | (buildNixOSConfigurations { inherit (nixos.x86_64-linux) hostNames; }) 24 | createPullRequestStep 25 | ]; 26 | }; 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /modules/shared/theme/default.nix: -------------------------------------------------------------------------------- 1 | { pkgs, lib, ... }: 2 | 3 | { 4 | imports = [ ./fonts.nix ]; 5 | 6 | options.theme = { 7 | colors = lib.mkOption { 8 | type = with lib.types; attrsOf str; 9 | description = "Base16 colors."; 10 | default = lib.importJSON ./colors.json; 11 | }; 12 | 13 | wallpaper = { 14 | path = lib.mkOption { 15 | type = lib.types.path; 16 | description = "Wallpaper path."; 17 | default = pkgs.wallpapers.hatsune-miku_walking-4k; 18 | }; 19 | scale = lib.mkOption { 20 | type = lib.types.enum [ 21 | "tile" 22 | "center" 23 | "fill" 24 | "scale" 25 | ]; 26 | default = "fill"; 27 | description = "Wallpaper scaling."; 28 | }; 29 | }; 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /packages/wallpapers/mkWallpaperImgur.nix: -------------------------------------------------------------------------------- 1 | # Based on: https://github.com/Misterio77/nix-config/blob/a1b9f1706bd0f9e18b90191bfca4eddcd3f070a8/pkgs/wallpapers/wallpaper.nix 2 | { 3 | lib, 4 | stdenvNoCC, 5 | fetchurl, 6 | }: 7 | { 8 | name, 9 | id, 10 | sha256, 11 | ext ? "jpg", 12 | }: 13 | 14 | stdenvNoCC.mkDerivation { 15 | name = "wallpaper-${name}.${ext}"; 16 | src = fetchurl { 17 | inherit sha256; 18 | url = "https://i.imgur.com/${id}.${ext}"; 19 | }; 20 | dontUnpack = true; 21 | 22 | installPhase = '' 23 | runHook preInstall 24 | 25 | install -Dm0644 "$src" "$out" 26 | 27 | runHook postInstall 28 | ''; 29 | 30 | meta = with lib; { 31 | description = "https://imgur.com/${id}"; 32 | platforms = platforms.all; 33 | license = licenses.unfree; 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /modules/nixos/dev/virtualisation/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | pkgs, 3 | lib, 4 | config, 5 | ... 6 | }: 7 | 8 | let 9 | inherit (config.nixos.home) username; 10 | cfg = config.nixos.dev.virtualisation; 11 | in 12 | { 13 | imports = [ ./libvirt.nix ]; 14 | 15 | options.nixos.dev.virtualisation = { 16 | enable = lib.mkEnableOption "virtualisation config" // { 17 | default = config.nixos.dev.enable; 18 | }; 19 | }; 20 | 21 | config = lib.mkIf cfg.enable { 22 | environment.systemPackages = with pkgs; [ 23 | distrobox 24 | podman-compose 25 | ]; 26 | 27 | virtualisation = { 28 | podman = { 29 | enable = true; 30 | dockerCompat = true; 31 | dockerSocket.enable = true; 32 | }; 33 | }; 34 | 35 | users.users.${username}.extraGroups = [ "podman" ]; 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /modules/home-manager/desktop/fonts/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | lib, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.home-manager.desktop.fonts; 10 | in 11 | { 12 | imports = [ ./fontconfig.nix ]; 13 | 14 | options.home-manager.desktop.fonts = { 15 | enable = lib.mkEnableOption "font config" // { 16 | default = config.home-manager.desktop.enable || config.home-manager.darwin.enable; 17 | }; 18 | }; 19 | 20 | config = lib.mkIf cfg.enable { 21 | home.packages = 22 | with pkgs; 23 | with config.theme.fonts; 24 | [ 25 | gui.package 26 | icons.package 27 | symbols.package 28 | # Noto fonts is a good fallback font 29 | noto-fonts 30 | noto-fonts-cjk-sans 31 | noto-fonts-cjk-serif 32 | noto-fonts-color-emoji 33 | ]; 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /modules/nixos/home.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | flake, 5 | pkgs, 6 | ... 7 | }: 8 | 9 | let 10 | cfg = config.nixos.home; 11 | in 12 | { 13 | imports = [ 14 | (flake.outputs.internal.sharedModules.helpers.mkHomeModule "nixos") 15 | flake.inputs.home-manager.nixosModules.home-manager 16 | ]; 17 | 18 | config = lib.mkIf cfg.enable { 19 | nixos.home.extraModules = { 20 | # As a rule of thumb HM == NixOS version, unless something weird happens 21 | home.stateVersion = lib.mkDefault config.system.stateVersion; 22 | }; 23 | 24 | # Define a user account. Don't forget to set a password with ‘passwd’ 25 | users.users.${cfg.username} = { 26 | isNormalUser = true; 27 | uid = 1000; 28 | extraGroups = [ 29 | "wheel" 30 | "video" 31 | ]; 32 | shell = pkgs.zsh; 33 | password = "changeme"; 34 | }; 35 | }; 36 | } 37 | -------------------------------------------------------------------------------- /packages/wallpapers/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | mkWallpaperImgur, 3 | }: 4 | 5 | { 6 | hatsune-miku_stylized-ultrawide = mkWallpaperImgur { 7 | name = "hatsune-miku_stylized-ultrawide"; 8 | id = "IMi5dxN"; 9 | sha256 = "sha256-9lOLxW6CmTjLHBDZPW3QYqBJEsTuv6yHodnprCUVYIM="; 10 | }; 11 | 12 | hatsune-miku_walking-4k = mkWallpaperImgur { 13 | name = "hatsune-miku_walking-4k"; 14 | id = "CpFAG3V"; 15 | sha256 = "sha256-aasxZ9r2Iv3uQKOscMtUIih2cHz1K3b8OfBQW4E585k="; 16 | }; 17 | 18 | hatsune-miku_starry-sky = mkWallpaperImgur { 19 | name = "hatsune-miku_starry-sky"; 20 | id = "f1WpcId"; 21 | sha256 = "sha256-iHQVryAwuOVttJZN60STmJ7+Qavyz7fntR9lcPk/E6I="; 22 | }; 23 | 24 | witch-hat-atelier_coco = mkWallpaperImgur { 25 | name = "witch-hat-atelier_coco"; 26 | id = "gU5QcCD"; 27 | sha256 = "sha256-BbT+Xp+Pn1W28tkV8mX580lAeaf6BJHBT5ojEXmywCM="; 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /modules/home-manager/dev/asdf.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | lib, 5 | ... 6 | }: 7 | 8 | { 9 | options.home-manager.dev.asdf.enable = lib.mkEnableOption "asdf config"; 10 | 11 | config = lib.mkIf config.home-manager.dev.asdf.enable { 12 | home = { 13 | activation.reshimAsdf = 14 | lib.hm.dag.entryAfter [ "writeBoundary" ] 15 | # bash 16 | '' 17 | run ${lib.getExe pkgs.asdf-vm} reshim 18 | ''; 19 | 20 | file.".asdfrc".text = lib.generators.toKeyValue { } { 21 | legacy_version_file = "yes"; 22 | }; 23 | 24 | packages = with pkgs; [ asdf-vm ]; 25 | }; 26 | 27 | programs.zsh = { 28 | initContent = 29 | # bash 30 | '' 31 | export PATH="''${ASDF_DATA_DIR:-''$HOME/.asdf}/shims:$PATH" 32 | fpath+=(${pkgs.asdf-vm}/share/zsh/site-functions) 33 | ''; 34 | }; 35 | }; 36 | } 37 | -------------------------------------------------------------------------------- /modules/home-manager/dev/nix.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | lib, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.home-manager.dev.nix; 10 | in 11 | { 12 | options.home-manager.dev.nix = { 13 | enable = lib.mkEnableOption "Nix config" // { 14 | default = config.home-manager.dev.enable; 15 | }; 16 | languageServer = lib.mkOption { 17 | type = lib.types.enum [ 18 | "nixd" 19 | "nil" 20 | ]; 21 | description = "Nix language server."; 22 | default = "nil"; 23 | }; 24 | }; 25 | 26 | config = lib.mkIf cfg.enable { 27 | home.packages = 28 | with pkgs; 29 | [ 30 | nix-tree 31 | nix-update 32 | nixfmt-rfc-style 33 | nurl 34 | nvd 35 | statix 36 | ] 37 | ++ lib.optionals (cfg.languageServer == "nil") [ nil ] 38 | ++ lib.optionals (cfg.languageServer == "nixd") [ nixd ]; 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /modules/nixos/desktop/tailscale.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | { 4 | options.nixos.desktop.tailscale.enable = lib.mkEnableOption "Tailscale config (client side)" // { 5 | default = config.nixos.desktop.enable; 6 | }; 7 | 8 | config = lib.mkMerge [ 9 | (lib.mkIf config.nixos.desktop.tailscale.enable { 10 | services.tailscale = { 11 | enable = true; 12 | useRoutingFeatures = if config.nixos.server.tailscale.enable then "both" else "client"; 13 | }; 14 | }) 15 | (lib.mkIf config.networking.networkmanager.enable { 16 | # Disable wait online as it's causing trouble at rebuild 17 | # See: https://github.com/NixOS/nixpkgs/issues/180175 18 | systemd.services.NetworkManager-wait-online.enable = false; 19 | # Restart tailscaled if NetworkManager service is restarted 20 | systemd.services.tailscaled.partOf = [ "NetworkManager.service" ]; 21 | }) 22 | ]; 23 | } 24 | -------------------------------------------------------------------------------- /modules/home-manager/cli/nixpkgs.nix: -------------------------------------------------------------------------------- 1 | { 2 | flake, 3 | config, 4 | pkgs, 5 | lib, 6 | ... 7 | }: 8 | 9 | { 10 | imports = [ flake.inputs.nix-index-database.homeModules.nix-index ]; 11 | 12 | options.home-manager.cli.nixpkgs.enable = lib.mkEnableOption "nixpkgs tools config" // { 13 | default = config.home-manager.cli.enable; 14 | }; 15 | 16 | config = lib.mkIf config.home-manager.cli.nixpkgs.enable { 17 | programs = { 18 | nix-index = { 19 | enable = true; 20 | symlinkToCacheHome = true; 21 | }; 22 | nix-index-database.comma.enable = true; 23 | }; 24 | 25 | home.packages = 26 | with pkgs; 27 | [ 28 | nix-output-monitor 29 | (nixpkgs-review.override { 30 | withNom = true; 31 | withSandboxSupport = pkgs.stdenv.isLinux; 32 | }) 33 | ] 34 | ++ lib.optionals stdenv.isLinux [ 35 | nix-alien 36 | ]; 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /modules/nixos/games/steam.nix: -------------------------------------------------------------------------------- 1 | { 2 | pkgs, 3 | lib, 4 | config, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.nixos.games.steam; 10 | in 11 | { 12 | options.nixos.games.steam = { 13 | enable = lib.mkEnableOption "Steam config" // { 14 | default = config.nixos.games.enable; 15 | }; 16 | }; 17 | 18 | config = lib.mkIf cfg.enable { 19 | environment.systemPackages = with pkgs; [ 20 | gamescope 21 | mangohud 22 | xwininfo # sh: line 1: xwininfo: command not found 23 | ]; 24 | 25 | programs = { 26 | gamescope = { 27 | args = [ "--rt" ]; 28 | capSysNice = true; 29 | }; 30 | 31 | steam = { 32 | enable = true; 33 | protontricks.enable = true; 34 | gamescopeSession.enable = !config.nixos.games.jovian.enable; 35 | remotePlay.openFirewall = true; 36 | localNetworkGameTransfers.openFirewall = true; 37 | }; 38 | }; 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /modules/home-manager/dev/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | lib, 5 | ... 6 | }: 7 | 8 | { 9 | imports = [ 10 | ./asdf.nix 11 | ./clojure.nix 12 | ./go.nix 13 | ./lua.nix 14 | ./nix.nix 15 | ./node.nix 16 | ./python.nix 17 | ]; 18 | 19 | options.home-manager.dev.enable = lib.mkEnableOption "dev config" // { 20 | default = config.home-manager.desktop.enable || config.home-manager.darwin.enable; 21 | }; 22 | 23 | config = lib.mkIf config.home-manager.dev.enable { 24 | home.packages = with pkgs; [ 25 | bash-language-server 26 | expect 27 | marksman 28 | shellcheck 29 | ]; 30 | 31 | programs.tealdeer = { 32 | enable = true; 33 | settings = { 34 | display = { 35 | compact = false; 36 | use_pager = true; 37 | }; 38 | updates = { 39 | auto_update = false; 40 | }; 41 | }; 42 | }; 43 | }; 44 | } 45 | -------------------------------------------------------------------------------- /modules/nixos/system/binfmt.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.nixos.system.binfmt; 10 | in 11 | { 12 | options.nixos.system.binfmt = { 13 | enable = lib.mkEnableOption "binfmt configuration"; 14 | windows.enable = lib.mkEnableOption "Windows emulation (via WINE)"; 15 | }; 16 | 17 | config = lib.mkIf cfg.enable { 18 | # Allow compilation of packages for other architectures (e.g.: ARM64) via 19 | # QEMU e.g. nix-build -A --argstr system aarch64-linux 20 | # https://nixos.wiki/wiki/NixOS_on_ARM#Compiling_through_QEMU 21 | boot.binfmt.emulatedSystems = 22 | ( 23 | { 24 | "x86_64-linux" = [ "aarch64-linux" ]; 25 | "aarch64-linux" = [ "x86_64-linux" ]; 26 | } 27 | .${pkgs.stdenv.hostPlatform.system} or [ ] 28 | ) 29 | ++ lib.optionals cfg.windows.enable [ 30 | "x86_64-windows" 31 | ]; 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /hosts/nix-darwin/Sekai-MacBook-Pro/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | nixpkgs.hostPlatform = "aarch64-darwin"; 3 | 4 | nix-darwin.home = { 5 | username = "thiago.okada"; 6 | extraModules = { 7 | home.stateVersion = "25.11"; 8 | home-manager = { 9 | cli.zsh.zprof.enable = true; 10 | dev.asdf.enable = true; 11 | editor.idea.enable = true; 12 | }; 13 | programs.go.env = { 14 | GOPRIVATE = "github.com/flowcommerce/*"; 15 | }; 16 | }; 17 | }; 18 | 19 | system.keyboard = { 20 | enableKeyMapping = true; 21 | remapCapsLockToEscape = true; 22 | nonUS.remapTilde = true; 23 | }; 24 | 25 | # This value determines the nix-darwin release with which your system is to 26 | # be compatible, in order to avoid breaking some software such as database 27 | # servers. You should change this only after nix-darwin release notes say you 28 | # should. 29 | system.stateVersion = 6; # Did you read the comment? 30 | } 31 | -------------------------------------------------------------------------------- /modules/nixos/server/watchdogd.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | let 8 | cfg = config.nixos.server.watchdogd; 9 | ping-watchdog = pkgs.writeShellScriptBin "ping-watchdog" '' 10 | /run/current-system/sw/bin/ping -c 4 8.8.8.8 11 | ''; 12 | logDirectory = "/var/lib/misc"; 13 | in 14 | { 15 | options.nixos.server.watchdogd = { 16 | enable = lib.mkEnableOption "watchdogd config"; 17 | }; 18 | 19 | config = lib.mkIf cfg.enable { 20 | environment.systemPackages = [ ping-watchdog ]; 21 | 22 | services.watchdogd = { 23 | enable = true; 24 | settings = { 25 | "generic /run/current-system/sw/bin/ping-watchdog" = { 26 | enabled = true; 27 | interval = 300; 28 | timeout = 60; 29 | critical = 1; 30 | }; 31 | reset-reason.file = "${logDirectory}/watchdogd.state"; 32 | }; 33 | }; 34 | 35 | systemd.tmpfiles.rules = [ "d ${logDirectory} 0700" ]; 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /hosts/nixos/zachune-nixos/disk-config.nix: -------------------------------------------------------------------------------- 1 | { 2 | disk = { 3 | sda = { 4 | device = "/dev/sda"; 5 | type = "disk"; 6 | content = { 7 | type = "gpt"; 8 | partitions = { 9 | ESP = { 10 | name = "esp"; 11 | size = "500M"; 12 | type = "EF00"; 13 | content = { 14 | type = "filesystem"; 15 | format = "vfat"; 16 | mountpoint = "/boot"; 17 | }; 18 | }; 19 | root = { 20 | name = "root"; 21 | end = "-2G"; 22 | content = { 23 | type = "filesystem"; 24 | format = "xfs"; 25 | mountpoint = "/"; 26 | }; 27 | }; 28 | swap = { 29 | name = "swap"; 30 | size = "100%"; 31 | content = { 32 | type = "swap"; 33 | }; 34 | }; 35 | }; 36 | }; 37 | }; 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /hosts/nixos/zatsune-nixos/disk-config.nix: -------------------------------------------------------------------------------- 1 | { 2 | disk = { 3 | sda = { 4 | device = "/dev/sda"; 5 | type = "disk"; 6 | content = { 7 | type = "gpt"; 8 | partitions = { 9 | ESP = { 10 | name = "esp"; 11 | size = "500M"; 12 | type = "EF00"; 13 | content = { 14 | type = "filesystem"; 15 | format = "vfat"; 16 | mountpoint = "/boot"; 17 | }; 18 | }; 19 | root = { 20 | name = "root"; 21 | end = "-12G"; 22 | content = { 23 | type = "filesystem"; 24 | format = "xfs"; 25 | mountpoint = "/"; 26 | }; 27 | }; 28 | swap = { 29 | name = "swap"; 30 | size = "100%"; 31 | content = { 32 | type = "swap"; 33 | }; 34 | }; 35 | }; 36 | }; 37 | }; 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /modules/home-manager/window-manager/x11/picom.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | { 4 | options.home-manager.window-manager.x11.picom.enable = lib.mkEnableOption "picom config" // { 5 | default = config.home-manager.window-manager.x11.enable; 6 | }; 7 | 8 | config = lib.mkIf config.home-manager.window-manager.x11.picom.enable { 9 | services.picom = { 10 | enable = true; 11 | backend = if config.home-manager.window-manager.x11.nvidia.enable then "glx" else "egl"; 12 | fade = true; 13 | fadeDelta = 2; 14 | vSync = true; 15 | settings = { 16 | unredir-if-possible = true; 17 | unredir-if-possible-exclude = [ "name *= 'Firefox'" ]; 18 | # https://github.com/google/xsecurelock/issues/97#issuecomment-1183086902 19 | fade-exclude = [ "class_g = 'xsecurelock'" ]; 20 | }; 21 | }; 22 | # Avoid restarting picom indefinitely in Wayland 23 | systemd.user.services.picom.Service.Restart = lib.mkForce "on-abnormal"; 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /modules/home-manager/dev/node.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | lib, 5 | ... 6 | }: 7 | 8 | let 9 | inherit (config.home) homeDirectory; 10 | in 11 | { 12 | options.home-manager.dev.node.enable = lib.mkEnableOption "NodeJS config" // { 13 | default = config.home-manager.dev.enable; 14 | }; 15 | 16 | config = lib.mkIf config.home-manager.dev.node.enable { 17 | home = { 18 | packages = with pkgs; [ 19 | nodejs 20 | typescript-language-server 21 | vscode-langservers-extracted 22 | yarn 23 | ]; 24 | 25 | sessionPath = [ "${homeDirectory}/.npm-packages/bin" ]; 26 | sessionVariables.NPM_PACKAGES = "${homeDirectory}/.npm-packages"; 27 | sessionSearchVariables = 28 | let 29 | inherit (config.home.sessionVariables) NPM_PACKAGES; 30 | in 31 | { 32 | NODE_PATH = [ "${NPM_PACKAGES}/lib/node_modules" ]; 33 | MANPATH = [ "${NPM_PACKAGES}/share/man" ]; 34 | }; 35 | }; 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /modules/nixos/server/plex.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | let 4 | inherit (config.nixos.home) username; 5 | inherit (config.device.media) directory; 6 | in 7 | with config.users.users.${username}; 8 | { 9 | options.nixos.server.plex.enable = lib.mkEnableOption "Plex config"; 10 | 11 | config = lib.mkIf config.nixos.server.plex.enable { 12 | # Increase number of directories that Linux can monitor for Plex 13 | boot.kernel.sysctl = { 14 | "fs.inotify.max_user_watches" = 524288; 15 | }; 16 | 17 | # Enable Plex Media Server 18 | services.plex = { 19 | enable = true; 20 | openFirewall = true; 21 | accelerationDevices = [ "*" ]; 22 | inherit group; 23 | }; 24 | 25 | systemd.tmpfiles.rules = [ 26 | "d ${directory}/Other 2775 ${username} ${group}" 27 | "d ${directory}/Music 2775 ${username} ${group}" 28 | "d ${directory}/Photos 2775 ${username} ${group}" 29 | "d ${directory}/Videos 2775 ${username} ${group}" 30 | ]; 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /modules/nixos/window-manager/default.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | { 4 | imports = [ 5 | ./greetd.nix 6 | ./wayland.nix 7 | ./xserver.nix 8 | ]; 9 | 10 | options.nixos.window-manager.enable = lib.mkEnableOption "window-manager config" // { 11 | default = builtins.any (x: config.device.type == x) [ 12 | "desktop" 13 | "laptop" 14 | ]; 15 | }; 16 | 17 | config = lib.mkIf config.nixos.window-manager.enable { 18 | nixos.home.extraModules = { 19 | home-manager.window-manager.enable = true; 20 | }; 21 | 22 | services = { 23 | gnome.gnome-keyring.enable = true; 24 | graphical-desktop.enable = true; 25 | udisks2.enable = true; 26 | }; 27 | 28 | # Make nm-applet restart in case of failure 29 | systemd.user.services.nm-applet = { 30 | serviceConfig = { 31 | # Use exponential restart 32 | RestartSteps = 5; 33 | RestartMaxDelaySec = 10; 34 | Restart = "on-failure"; 35 | }; 36 | }; 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /modules/nix-darwin/nix/linux-builder.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | ... 5 | }: 6 | 7 | let 8 | cfg = config.nix-darwin.nix.linux-builder; 9 | in 10 | { 11 | options.nix-darwin.nix.linux-builder.enable = lib.mkEnableOption "Linux builder config"; 12 | 13 | config = lib.mkIf cfg.enable { 14 | launchd.daemons.linux-builder = { 15 | serviceConfig = { 16 | StandardOutPath = "/var/log/darwin-builder.log"; 17 | StandardErrorPath = "/var/log/darwin-builder.log"; 18 | }; 19 | }; 20 | 21 | nix.linux-builder = { 22 | enable = true; 23 | ephemeral = true; 24 | maxJobs = 4; 25 | systems = [ "aarch64-linux" ]; 26 | config = { 27 | # https://github.com/LnL7/nix-darwin/issues/913 28 | services.openssh.enable = true; 29 | virtualisation = { 30 | darwin-builder = { 31 | diskSize = 40 * 1024; 32 | memorySize = 8 * 1024; 33 | }; 34 | cores = 6; 35 | }; 36 | }; 37 | }; 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /.github/workflows/validate-flakes.yml: -------------------------------------------------------------------------------- 1 | concurrency: 2 | cancel-in-progress: true 3 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} 4 | jobs: 5 | build-x86_64-linux: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@v5 9 | - uses: cachix/install-nix-action@v31 10 | with: 11 | extra_nix_config: |- 12 | accept-flake-config = true 13 | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} 14 | nix_path: nixpkgs=channel:nixos-unstable 15 | - uses: cachix/cachix-action@v16 16 | with: 17 | authToken: ${{ secrets.CACHIX_TOKEN }} 18 | extraPullNames: nix-community,chaotic-nyx 19 | name: thiagokokada-nix-configs 20 | - name: nix-info -m 21 | run: | 22 | nix run '.#nix-info' -- -m 23 | - name: Validate Flakes 24 | run: nix flake check --all-systems --print-build-logs 25 | name: validate-flakes 26 | "on": 27 | - push 28 | - workflow_dispatch 29 | -------------------------------------------------------------------------------- /modules/home-manager/cli/ssh/ssh-agent.zsh: -------------------------------------------------------------------------------- 1 | zmodload zsh/net/socket 2 | 3 | _check_agent(){ 4 | if [[ -S "$SSH_AUTH_SOCK" ]] && zsocket "$SSH_AUTH_SOCK" 2>/dev/null; then 5 | return 0 6 | fi 7 | return 1 8 | } 9 | 10 | _start_agent() { 11 | # Test if $SSH_AUTH_SOCK is visible, in case we start e.g.: ssh-agent via 12 | # systemd service 13 | if _check_agent; then 14 | return 0 15 | fi 16 | 17 | # Get the filename to store/lookup the environment from 18 | local -r ssh_env_cache="$HOME/.ssh-agent" 19 | 20 | # Check if ssh-agent is already running 21 | if [[ -f "$ssh_env_cache" ]]; then 22 | source "$ssh_env_cache" > /dev/null 23 | 24 | # Test if $SSH_AUTH_SOCK is visible, e.g.: the ssh-agent is still alive 25 | if _check_agent; then 26 | return 0 27 | fi 28 | fi 29 | 30 | # start ssh-agent and setup environment 31 | ( 32 | umask 066 33 | ssh-agent -s >! "$ssh_env_cache" 34 | ) 35 | source "$ssh_env_cache" > /dev/null 36 | } 37 | 38 | _start_agent 39 | unfunction _check_agent _start_agent 40 | -------------------------------------------------------------------------------- /modules/nixos/laptop/default.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | { 4 | imports = [ 5 | ./tlp.nix 6 | ]; 7 | 8 | options.nixos.laptop.enable = lib.mkEnableOption "laptop config" // { 9 | default = config.device.type == "laptop"; 10 | }; 11 | 12 | config = lib.mkIf config.nixos.laptop.enable { 13 | # Configure hibernation 14 | boot.resumeDevice = lib.mkIf (config.swapDevices != [ ]) ( 15 | lib.mkDefault (builtins.head config.swapDevices).device 16 | ); 17 | 18 | # Enable laptop specific services 19 | services = { 20 | # For battery status reporting 21 | upower.enable = true; 22 | 23 | logind = { 24 | settings.Login = { 25 | HandlePowerKey = "suspend-then-hibernate"; 26 | HandleLidSwitch = "suspend-then-hibernate"; 27 | # Only suspend on lid closed when laptop is disconnected 28 | HandleLidSwitchDocked = lib.mkDefault "ignore"; 29 | HandleLidSwitchExternalPower = lib.mkDefault "lock"; 30 | }; 31 | }; 32 | }; 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /modules/home-manager/window-manager/x11/wallpaper.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | { 9 | options.home-manager.window-manager.x11.wallpaper.enable = 10 | lib.mkEnableOption "wallpaper config" 11 | // { 12 | default = config.home-manager.window-manager.x11.enable; 13 | }; 14 | 15 | config = lib.mkIf config.home-manager.window-manager.x11.wallpaper.enable { 16 | systemd.user.services = { 17 | wallpaper = { 18 | Unit = { 19 | Description = "set wallpaper"; 20 | After = [ "graphical-session-pre.target" ]; 21 | PartOf = [ "graphical-session.target" ]; 22 | }; 23 | 24 | Install.WantedBy = [ "graphical-session.target" ]; 25 | 26 | Service = with config.theme.wallpaper; { 27 | ExecStart = lib.escapeShellArgs [ 28 | (lib.getExe pkgs.feh) 29 | "--no-fehbg" 30 | "--bg-${scale}" 31 | path 32 | ]; 33 | Type = "oneshot"; 34 | }; 35 | }; 36 | }; 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /modules/nixos/desktop/wireless.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | lib, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.nixos.desktop.wireless; 10 | in 11 | { 12 | options.nixos.desktop.wireless = { 13 | enable = lib.mkEnableOption "Wi-Fi/Bluetooth config" // { 14 | default = config.nixos.desktop.enable; 15 | }; 16 | }; 17 | 18 | config = lib.mkIf cfg.enable { 19 | # Install Wireless related packages 20 | environment.systemPackages = with pkgs; [ iw ]; 21 | 22 | programs.nm-applet.enable = lib.mkDefault config.nixos.window-manager.enable; 23 | 24 | networking = { 25 | # Use Network Manager 26 | networkmanager = { 27 | enable = true; 28 | wifi.backend = lib.mkDefault "iwd"; 29 | }; 30 | }; 31 | 32 | # Enable bluetooth 33 | hardware.bluetooth.enable = true; 34 | 35 | # Enable Blueman to manage Bluetooth 36 | services.blueman.enable = config.nixos.window-manager.enable; 37 | 38 | users.users.${config.nixos.home.username}.extraGroups = [ "networkmanager" ]; 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /modules/home-manager/meta/restore-backups.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | let 4 | cfg = config.home-manager.meta.restoreBackups; 5 | in 6 | { 7 | options.home-manager.meta.restoreBackups = { 8 | backupFileExtension = lib.mkOption { 9 | description = "File extension to remove before activation."; 10 | type = with lib.types; nullOr str; 11 | default = null; 12 | }; 13 | }; 14 | 15 | config = lib.mkIf (cfg.backupFileExtension != null) { 16 | home.activation.restoreBackups = 17 | lib.hm.dag.entryAfter [ "linkGeneration" ] 18 | # bash 19 | '' 20 | (find "$HOME" -type f -name "*.${cfg.backupFileExtension}" 2>/dev/null || true) | while IFS= read -r file; do 21 | base="''${file%.${cfg.backupFileExtension}}" 22 | if [[ ! -e "$base" ]]; then 23 | echo "Renaming: $file -> $base" 24 | run mv $VERBOSE_ARG -- "$file" "$base" 25 | else 26 | echo "Skipping: $file (because $base exists)" 27 | fi 28 | done 29 | ''; 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /templates/new-host/hosts/nixos/new-host/default.nix: -------------------------------------------------------------------------------- 1 | # Edit this configuration file to define what should be installed on 2 | # your system. Help is available in the configuration.nix(5) man page 3 | # and in the NixOS manual (accessible by running ‘nixos-help’). 4 | 5 | { ... }: 6 | 7 | { 8 | imports = [ 9 | # Use `nixos-generate-config` to generate `hardware-configuration.nix` file 10 | ./hardware-configuration.nix 11 | # inputs.hardware.nixosModules.common-cpu-intel 12 | ]; 13 | 14 | device = { 15 | type = "laptop"; 16 | net.ifaces = [ 17 | "enp3s0" 18 | "wlan0" 19 | ]; 20 | }; 21 | 22 | # Use the systemd-boot EFI boot loader. 23 | boot.loader.systemd-boot.enable = true; 24 | boot.loader.efi.canTouchEfiVariables = true; 25 | 26 | # This value determines the NixOS release with which your system is to be 27 | # compatible, in order to avoid breaking some software such as database 28 | # servers. You should change this only after NixOS release notes say you 29 | # should. 30 | system.stateVersion = "24.05"; # Did you read the comment? 31 | } 32 | -------------------------------------------------------------------------------- /modules/home-manager/meta/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.home-manager.meta; 10 | in 11 | { 12 | imports = [ 13 | ./diff.nix 14 | ./restore-backups.nix 15 | ]; 16 | 17 | options.home-manager.meta = { 18 | enable = lib.mkEnableOption "Home-Manager config" // { 19 | default = true; 20 | }; 21 | autoExpire.enable = lib.mkEnableOption "auto expire Home-Manager generations" // { 22 | default = pkgs.stdenv.isLinux; 23 | }; 24 | }; 25 | 26 | config = lib.mkIf cfg.enable { 27 | programs = { 28 | # Let Home Manager install and manage itself 29 | home-manager.enable = true; 30 | # Without git we may be unable to build this config 31 | git.enable = true; 32 | }; 33 | 34 | services.home-manager.autoExpire = { 35 | inherit (cfg.autoExpire) enable; 36 | timestamp = "-7 days"; 37 | frequency = "3:05"; 38 | store.cleanup = true; 39 | }; 40 | 41 | # More reliable user service restart 42 | systemd.user.startServices = lib.mkDefault "sd-switch"; 43 | }; 44 | } 45 | -------------------------------------------------------------------------------- /modules/nix-darwin/homebrew.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | let 4 | cfg = config.nix-darwin.homebrew; 5 | inherit (config.nix-darwin.home) username; 6 | in 7 | { 8 | options.nix-darwin.homebrew = { 9 | enable = lib.mkEnableOption "Homebrew config" // { 10 | default = true; 11 | }; 12 | }; 13 | 14 | config = lib.mkIf cfg.enable { 15 | nix-darwin.home.extraModules = { 16 | home-manager.editor.idea.packages = null; 17 | programs = { 18 | firefox.package = null; 19 | kitty.package = null; 20 | }; 21 | }; 22 | 23 | homebrew = { 24 | enable = true; 25 | user = config.nix-darwin.home.username; 26 | casks = [ 27 | "betterdisplay" 28 | "domzilla-caffeine" 29 | "firefox" 30 | "google-chrome" 31 | "intellij-idea-ce" 32 | "kitty" 33 | "linearmouse" 34 | "rectangle" 35 | ]; 36 | }; 37 | 38 | home-manager.users.${username}.home-manager.darwin.homebrew = { 39 | enable = true; 40 | prefix = lib.removeSuffix "/bin" config.homebrew.brewPrefix; 41 | }; 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /modules/nixos/desktop/fonts.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | lib, 5 | ... 6 | }: 7 | 8 | { 9 | options.nixos.desktop.fonts.enable = lib.mkEnableOption "fonts config" // { 10 | default = config.nixos.desktop.enable; 11 | }; 12 | 13 | config = lib.mkIf config.nixos.desktop.fonts.enable { 14 | nixos.home.extraModules = { 15 | fonts.fontconfig = with config.fonts.fontconfig; { 16 | enable = true; 17 | antialiasing = antialias; 18 | hinting = lib.mkIf hinting.enable hinting.style; 19 | subpixelRendering = subpixel.rgba; 20 | }; 21 | }; 22 | 23 | fonts = { 24 | fontDir.enable = true; 25 | 26 | packages = with pkgs; [ 27 | noto-fonts 28 | noto-fonts-cjk-sans 29 | noto-fonts-cjk-serif 30 | noto-fonts-color-emoji 31 | ]; 32 | 33 | fontconfig = { 34 | defaultFonts = { 35 | monospace = [ "Noto Sans Mono" ]; 36 | serif = [ "Noto Serif" ]; 37 | sansSerif = [ "Noto Sans" ]; 38 | emoji = [ "Noto Color Emoji" ]; 39 | }; 40 | }; 41 | }; 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /modules/nixos/laptop/tlp.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | let 4 | cfg = config.nixos.laptop.tlp; 5 | in 6 | { 7 | options.nixos.laptop.tlp = { 8 | enable = lib.mkEnableOption "TLP config" // { 9 | default = !config.services.power-profiles-daemon.enable && config.nixos.laptop.enable; 10 | }; 11 | }; 12 | 13 | config = lib.mkIf cfg.enable { 14 | # This will set CPU_SCALING_GOVERNOR_ON_{AC,BAT} options in TLP 15 | # 1200 is more priority than mkOptionDefault, less than mkDefault 16 | powerManagement.cpuFreqGovernor = lib.mkOverride 1200 "ondemand"; 17 | 18 | # Reduce power consumption 19 | services.tlp = { 20 | enable = true; 21 | # https://linrunner.de/tlp/support/optimizing.html 22 | settings = { 23 | # Enable the platform profile low-power 24 | PLATFORM_PROFILE_ON_BAT = lib.mkDefault "balanced"; 25 | # Enable the platform profile performance 26 | PLATFORM_PROFILE_ON_AC = lib.mkDefault "performance"; 27 | # Enable runtime power management 28 | RUNTIME_PM_ON_AC = lib.mkDefault "auto"; 29 | }; 30 | }; 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021-2025 Thiago Kenji Okada 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /hosts/nixos/zachune-nixos/hardware-configuration.nix: -------------------------------------------------------------------------------- 1 | # Do not modify this file! It was generated by ‘nixos-generate-config’ 2 | # and may be overwritten by future invocations. Please make changes 3 | # to /etc/nixos/configuration.nix instead. 4 | { 5 | lib, 6 | modulesPath, 7 | ... 8 | }: 9 | 10 | { 11 | imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; 12 | 13 | boot.initrd.availableKernelModules = [ 14 | "xhci_pci" 15 | "virtio_pci" 16 | "virtio_scsi" 17 | "usbhid" 18 | ]; 19 | boot.initrd.kernelModules = [ ]; 20 | boot.kernelModules = [ ]; 21 | boot.extraModulePackages = [ ]; 22 | 23 | # Enables DHCP on each ethernet and wireless interface. In case of scripted networking 24 | # (the default) this is the recommended approach. When using systemd-networkd it's 25 | # still possible to use this option, but it's recommended to use it in conjunction 26 | # with explicit per-interface declarations with `networking.interfaces..useDHCP`. 27 | networking.useDHCP = lib.mkDefault true; 28 | # networking.interfaces.enp0s6.useDHCP = lib.mkDefault true; 29 | 30 | nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; 31 | } 32 | -------------------------------------------------------------------------------- /hosts/nixos/zatsune-nixos/hardware-configuration.nix: -------------------------------------------------------------------------------- 1 | # Do not modify this file! It was generated by ‘nixos-generate-config’ 2 | # and may be overwritten by future invocations. Please make changes 3 | # to /etc/nixos/configuration.nix instead. 4 | { 5 | lib, 6 | modulesPath, 7 | ... 8 | }: 9 | 10 | { 11 | imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; 12 | 13 | boot.initrd.availableKernelModules = [ 14 | "xhci_pci" 15 | "virtio_pci" 16 | "virtio_scsi" 17 | "usbhid" 18 | ]; 19 | boot.initrd.kernelModules = [ ]; 20 | boot.kernelModules = [ ]; 21 | boot.extraModulePackages = [ ]; 22 | 23 | # Enables DHCP on each ethernet and wireless interface. In case of scripted networking 24 | # (the default) this is the recommended approach. When using systemd-networkd it's 25 | # still possible to use this option, but it's recommended to use it in conjunction 26 | # with explicit per-interface declarations with `networking.interfaces..useDHCP`. 27 | networking.useDHCP = lib.mkDefault true; 28 | # networking.interfaces.enp0s6.useDHCP = lib.mkDefault true; 29 | 30 | nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux"; 31 | } 32 | -------------------------------------------------------------------------------- /modules/nixos/nix/remote-builders.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | let 4 | cfg = config.nixos.nix.remote-builders; 5 | in 6 | { 7 | options.nixos.nix.remote-builders.enable = 8 | lib.mkEnableOption "remote-builders config for nixpkgs" 9 | // { 10 | default = config.nixos.desktop.tailscale.enable; 11 | }; 12 | 13 | config = lib.mkIf cfg.enable { 14 | # Compile via remote builders+Tailscale 15 | nix = { 16 | buildMachines = [ 17 | { 18 | hostName = "zatsune-nixos-br.quokka-char.ts.net"; 19 | system = "aarch64-linux"; 20 | protocol = "ssh-ng"; 21 | maxJobs = 4; 22 | # base64 -w0 /etc/ssh/ssh_host__key.pub 23 | publicHostKey = "c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUZEbENUZlZyQUlIVFI0T1RSMENtL2FUdUhOQmdEcE5RMFBncDEvaWFQaFAgcm9vdEB6YXRzdW5lLW5peG9zCg=="; 24 | supportedFeatures = [ 25 | "nixos-test" 26 | "benchmark" 27 | "big-parallel" 28 | "kvm" 29 | ]; 30 | } 31 | ]; 32 | 33 | distributedBuilds = true; 34 | 35 | settings = { 36 | builders-use-substitutes = true; 37 | }; 38 | }; 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /modules/nixos/server/ssh.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | let 4 | inherit (config.nixos.home) username; 5 | cfg = config.nixos.server.ssh; 6 | in 7 | { 8 | options.nixos.server.ssh = { 9 | enable = lib.mkEnableOption "SSH config"; 10 | authorizedKeys = lib.mkOption { 11 | description = "List of authorized keys."; 12 | type = lib.types.listOf lib.types.str; 13 | default = [ 14 | "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB2emux6tprbzXmtykaW44sSd4o7e7E2wAWZMFBSUb87 thiagokokada@gmail.com" 15 | ]; 16 | }; 17 | root.enableLogin = lib.mkEnableOption "root login via SSH"; 18 | }; 19 | 20 | config = lib.mkIf cfg.enable { 21 | # Enable OpenSSH 22 | services.openssh = { 23 | enable = true; 24 | ports = [ 25 | 22 26 | 2222 27 | ]; 28 | settings = { 29 | PasswordAuthentication = false; 30 | KbdInteractiveAuthentication = false; 31 | }; 32 | }; 33 | 34 | # Enable mosh 35 | programs.mosh.enable = true; 36 | 37 | # Add SSH key 38 | users.users.root.openssh.authorizedKeys.keys = lib.mkIf cfg.root.enableLogin cfg.authorizedKeys; 39 | users.extraUsers.${username}.openssh.authorizedKeys.keys = cfg.authorizedKeys; 40 | }; 41 | } 42 | -------------------------------------------------------------------------------- /lib/attrsets.nix: -------------------------------------------------------------------------------- 1 | { nixpkgs, ... }: 2 | 3 | let 4 | inherit (nixpkgs) lib; 5 | in 6 | rec { 7 | # Recursively merge a list of attrsets into a single attrset. 8 | # 9 | # nix-repl> recursiveMergeAttrs [ { a = "foo"; } { b = "bar"; } ]; 10 | # { a = "foo"; b = "bar"; } 11 | # nix-repl> recursiveMergeAttrs [ { a.b = "foo"; } { a.c = "bar"; } ] 12 | # { a = { b = "foo"; c = "bar"; }; } 13 | recursiveMergeAttrs = builtins.foldl' lib.recursiveUpdate { }; 14 | 15 | # Builds a map from =value to .=value for each system. 16 | eachSystem = 17 | systems: f: 18 | lib.foldAttrs lib.mergeAttrs { } (map (s: lib.mapAttrs (_: v: { ${s} = v; }) (f s)) systems); 19 | 20 | eachDefaultSystem = eachSystem [ 21 | "aarch64-linux" 22 | "aarch64-darwin" 23 | "x86_64-darwin" 24 | "x86_64-linux" 25 | ]; 26 | 27 | # Call function to each directory inside a dir. 28 | # 29 | # Will return a list of attrs. 30 | mapDir = 31 | f: dir: 32 | (lib.mapAttrsToList (curDir: type: lib.optionalAttrs (type == "directory") (f curDir)) ( 33 | builtins.readDir dir 34 | )); 35 | 36 | # Translate the keys from a attrset. 37 | translateKeys = trans: attrset: lib.mapAttrs' (n: v: lib.nameValuePair (trans.${n} or n) v) attrset; 38 | } 39 | -------------------------------------------------------------------------------- /modules/home-manager/nix/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | flake, 6 | ... 7 | }: 8 | 9 | let 10 | cfg = config.home-manager.nix; 11 | in 12 | { 13 | options.home-manager.nix.enable = lib.mkEnableOption "Nix config" // { 14 | default = true; 15 | }; 16 | 17 | config = lib.mkIf cfg.enable { 18 | home = { 19 | # Add some Nix related packages 20 | packages = with pkgs; [ 21 | nix-cleanup 22 | nix-whereis 23 | ]; 24 | # For standalone HM usage to make e.g.: nix-shell work as expected 25 | sessionVariables.NIX_PATH = "nixpkgs=${flake.inputs.nixpkgs}"; 26 | }; 27 | 28 | # To make cachix work you need add the current user as a trusted-user on Nix 29 | # sudo echo "trusted-users = $(whoami)" >> /etc/nix/nix.conf 30 | # Another option is to add a group by prefixing it by @, e.g.: 31 | # sudo echo "trusted-users = @wheel" >> /etc/nix/nix.conf 32 | nix = { 33 | package = lib.mkDefault pkgs.nix; 34 | settings = flake.outputs.internal.configs.nix; 35 | }; 36 | 37 | # Config for ad-hoc nix commands invocation 38 | xdg.configFile."nixpkgs/config.nix".text = 39 | lib.generators.toPretty { } 40 | flake.outputs.internal.configs.nixpkgs; 41 | }; 42 | } 43 | -------------------------------------------------------------------------------- /modules/nixos/window-manager/greetd.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | { 9 | options.nixos.window-manager.greetd.enable = lib.mkEnableOption "greetd config" // { 10 | default = config.nixos.window-manager.enable; 11 | }; 12 | 13 | config = lib.mkIf config.nixos.window-manager.greetd.enable { 14 | boot.consoleLogLevel = lib.mkDefault 3; 15 | 16 | services = { 17 | # Configure greetd, a lightweight session manager 18 | greetd = { 19 | enable = true; 20 | settings = { 21 | default_session = 22 | let 23 | inherit (config.services.displayManager.sessionData) desktops; 24 | in 25 | { 26 | command = lib.escapeShellArgs [ 27 | (lib.getExe pkgs.tuigreet) 28 | "--remember" 29 | "--remember-session" 30 | "--time" 31 | "--sessions" 32 | "${lib.concatStringsSep ":" ( 33 | builtins.map (path: "${desktops}/${path}") [ 34 | "share/xsessions" 35 | "share/wayland-sessions" 36 | ] 37 | )}" 38 | ]; 39 | }; 40 | }; 41 | }; 42 | }; 43 | }; 44 | } 45 | -------------------------------------------------------------------------------- /modules/home-manager/darwin/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.home-manager.darwin; 10 | in 11 | { 12 | imports = [ 13 | ./homebrew.nix 14 | ]; 15 | 16 | options.home-manager.darwin = { 17 | enable = lib.mkEnableOption "Darwin (macOS) config" // { 18 | default = pkgs.stdenv.isDarwin; 19 | }; 20 | }; 21 | 22 | config = lib.mkIf cfg.enable { 23 | targets.darwin.defaults = { 24 | NSGlobalDomain = { 25 | ApplePressAndHoldEnabled = false; 26 | AppleShowAllExtensions = true; 27 | KeyRepeat = 2; 28 | # Disable all automatic substitution 29 | NSAutomaticCapitalizationEnabled = false; 30 | NSAutomaticDashSubstitutionEnabled = false; 31 | NSAutomaticPeriodSubstitutionEnabled = false; 32 | NSAutomaticQuoteSubstitutionEnabled = false; 33 | NSAutomaticSpellingCorrectionEnabled = false; 34 | }; 35 | # Do not write .DS_Store files outside macOS 36 | com.apple.desktopservices = { 37 | DSDontWriteNetworkStores = true; 38 | DSDontWriteUSBStores = true; 39 | }; 40 | # Disable mouse acceleration 41 | com.apple.mouse.scalling = -1; 42 | # com.apple.trackpad.scalling = -1; 43 | }; 44 | }; 45 | } 46 | -------------------------------------------------------------------------------- /modules/nixos/system/cli.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | lib, 5 | ... 6 | }: 7 | 8 | { 9 | options.nixos.system.cli.enable = lib.mkEnableOption "CLI config" // { 10 | default = config.nixos.system.enable; 11 | }; 12 | 13 | config = lib.mkIf config.nixos.system.cli.enable { 14 | # CLI packages. 15 | environment = { 16 | # To get zsh completion for system packages 17 | pathsToLink = [ "/share/zsh" ]; 18 | 19 | systemPackages = 20 | with pkgs; 21 | with config.boot.kernelPackages; 22 | [ 23 | cpupower 24 | lm_sensors 25 | lshw 26 | mesa-demos 27 | pciutils 28 | powertop 29 | psmisc 30 | usbutils 31 | ]; 32 | }; 33 | 34 | # Enable programs that need special configuration. 35 | programs = { 36 | git.enable = true; 37 | iftop.enable = true; 38 | mtr.enable = true; 39 | neovim = { 40 | enable = true; 41 | defaultEditor = true; 42 | viAlias = true; 43 | vimAlias = true; 44 | withRuby = false; 45 | withNodeJs = false; 46 | }; 47 | traceroute.enable = true; 48 | zsh = { 49 | enable = true; 50 | enableCompletion = false; 51 | }; 52 | }; 53 | }; 54 | } 55 | -------------------------------------------------------------------------------- /modules/home-manager/window-manager/wayland/kanshi/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | lib, 3 | pkgs, 4 | config, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.home-manager.window-manager.wayland.kanshi; 10 | in 11 | { 12 | options.home-manager.window-manager.wayland.kanshi = { 13 | enable = lib.mkEnableOption "Kanshi config" // { 14 | default = config.home-manager.window-manager.wayland.enable; 15 | }; 16 | extraSettings = lib.mkOption { 17 | description = "Additional hooks."; 18 | type = lib.types.listOf lib.types.attrs; 19 | default = 20 | let 21 | inherit (config.home-manager) hostName; 22 | configFile = ./${hostName}.nix; 23 | in 24 | lib.optionals (builtins.pathExists configFile) (import configFile); 25 | }; 26 | }; 27 | 28 | config = lib.mkIf cfg.enable { 29 | # Useful to get the list of monitors 30 | home.packages = with pkgs; [ wlr-randr ]; 31 | 32 | services.kanshi = { 33 | enable = true; 34 | settings = cfg.extraSettings; 35 | }; 36 | 37 | systemd.user.services.kanshi = { 38 | Service = { 39 | inherit (config.home-manager.window-manager.systemd.service) 40 | RestartSec 41 | RestartSteps 42 | RestartMaxDelaySec 43 | ; 44 | }; 45 | }; 46 | }; 47 | } 48 | -------------------------------------------------------------------------------- /modules/home-manager/window-manager/theme/gtk.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | lib, 5 | ... 6 | }: 7 | 8 | { 9 | options.home-manager.window-manager.theme.gtk.enable = lib.mkEnableOption "GTK theme config" // { 10 | default = config.home-manager.window-manager.theme.enable; 11 | }; 12 | 13 | config = lib.mkIf config.home-manager.window-manager.theme.gtk.enable { 14 | home = { 15 | packages = with pkgs; [ 16 | gnome-themes-extra 17 | hicolor-icon-theme 18 | ]; 19 | }; 20 | 21 | gtk = { 22 | enable = true; 23 | font = { 24 | package = pkgs.noto-fonts; 25 | name = "Noto Sans"; 26 | }; 27 | iconTheme = { 28 | package = pkgs.nordzy-icon-theme; 29 | name = "Nordzy-dark"; 30 | }; 31 | theme = { 32 | name = "Nordic-bluish-accent"; 33 | package = pkgs.nordic; 34 | }; 35 | }; 36 | 37 | services.xsettingsd = { 38 | enable = true; 39 | settings = with config; { 40 | # When running, most GNOME/GTK+ applications prefer those settings 41 | # instead of *.ini files 42 | "Net/IconThemeName" = gtk.iconTheme.name; 43 | "Net/ThemeName" = gtk.theme.name; 44 | "Gtk/CursorThemeName" = xsession.pointerCursor.name; 45 | }; 46 | }; 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /modules/home-manager/darwin/homebrew.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.home-manager.darwin.homebrew; 10 | in 11 | { 12 | options.home-manager.darwin.homebrew = { 13 | enable = lib.mkEnableOption "Homebrew config"; 14 | prefix = lib.mkOption { 15 | type = lib.types.path; 16 | description = "Homebrew's prefix"; 17 | default = if pkgs.stdenv.hostPlatform.isAarch64 then "/opt/homebrew" else "/usr/local"; 18 | }; 19 | }; 20 | 21 | config = lib.mkIf cfg.enable { 22 | programs.zsh = { 23 | initContent = 24 | lib.mkOrder 550 # bash 25 | '' 26 | if [[ -f "${cfg.prefix}/bin/brew" ]]; then 27 | export HOMEBREW_NO_ENV_HINTS=1 28 | export HOMEBREW_NO_ANALYTICS=1 29 | export HOMEBREW_PREFIX="${cfg.prefix}" 30 | export HOMEBREW_CELLAR="${cfg.prefix}/Cellar" 31 | export HOMEBREW_REPOSITORY="${cfg.prefix}" 32 | fpath[1,0]="${cfg.prefix}/share/zsh/site-functions" 33 | export PATH="${cfg.prefix}/bin:${cfg.prefix}/sbin:$PATH" 34 | [ -z "''${MANPATH-}" ] || export MANPATH=":''${MANPATH#:}"; 35 | export INFOPATH="${cfg.prefix}/share/info:''${INFOPATH:-}" 36 | fi 37 | ''; 38 | }; 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /actions/constants.nix: -------------------------------------------------------------------------------- 1 | { 2 | actions = { 3 | # https://github.com/marketplace/actions/cachix 4 | cachix-action = "cachix/cachix-action@v16"; 5 | # https://github.com/marketplace/actions/checkout 6 | checkout = "actions/checkout@v5"; 7 | # https://github.com/marketplace/actions/create-pull-request 8 | create-pull-request = "peter-evans/create-pull-request@v7"; 9 | # https://github.com/marketplace/actions/free-disk-space-ubuntu 10 | free-disk-space = "thiagokokada/free-disk-space@main"; 11 | # https://github.com/marketplace/actions/install-nix 12 | install-nix-action = "cachix/install-nix-action@v31"; 13 | }; 14 | 15 | ubuntu.runs-on = "ubuntu-latest"; 16 | ubuntu-arm.runs-on = "ubuntu-24.04-arm"; 17 | macos.runs-on = "macos-latest"; 18 | 19 | home-manager = { 20 | x86_64-linux.hostNames = [ 21 | "home-linux" 22 | "steamdeck" 23 | ]; 24 | aarch64-linux.hostNames = [ "penguin" ]; 25 | aarch64-darwin.hostNames = [ "home-macos" ]; 26 | }; 27 | 28 | nix-darwin.aarch64-darwin.hostNames = [ "Sekai-MacBook-Pro" ]; 29 | 30 | nixos = { 31 | aarch64-linux.hostNames = [ 32 | "zatsune-nixos" 33 | ]; 34 | x86_64-linux.hostNames = [ 35 | "blackrockshooter-nixos" 36 | "hachune-nixos" 37 | "sankyuu-nixos" 38 | "zachune-nixos" 39 | ]; 40 | }; 41 | } 42 | -------------------------------------------------------------------------------- /modules/nix-darwin/nix/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | libEx, 5 | pkgs, 6 | flake, 7 | ... 8 | }: 9 | 10 | let 11 | cfg = config.nix-darwin.nix; 12 | in 13 | { 14 | imports = [ ./linux-builder.nix ]; 15 | 16 | options.nix-darwin.nix.enable = lib.mkEnableOption "nix/nixpkgs config" // { 17 | default = true; 18 | }; 19 | 20 | config = lib.mkIf cfg.enable { 21 | environment.systemPackages = with pkgs; [ darwin-cleanup ]; 22 | 23 | nix = { 24 | gc = { 25 | automatic = true; 26 | options = "--delete-older-than 7d"; 27 | }; 28 | 29 | # Customized nixpkgs, e.g.: `nix shell nixpkgs_#snes9x` 30 | registry.nixpkgs_.flake = flake; 31 | 32 | settings = lib.mkMerge [ 33 | # Needs to use substituters/trusted-public-keys otherwise it doesn't 34 | # work in nix-daemon 35 | (libEx.translateKeys { 36 | "extra-substituters" = "substituters"; 37 | "extra-trusted-public-keys" = "trusted-public-keys"; 38 | } flake.outputs.internal.configs.nix) 39 | { 40 | trusted-users = [ 41 | "root" 42 | "@admin" 43 | ]; 44 | } 45 | ]; 46 | }; 47 | 48 | nixpkgs = { 49 | config = flake.outputs.internal.configs.nixpkgs; 50 | overlays = [ flake.outputs.overlays.default ]; 51 | }; 52 | }; 53 | } 54 | -------------------------------------------------------------------------------- /modules/shared/device.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | { 4 | options.device = { 5 | type = lib.mkOption { 6 | type = lib.types.enum [ 7 | "desktop" 8 | "laptop" 9 | "server" 10 | "steam-machine" 11 | "vm" 12 | ]; 13 | description = "Type of device."; 14 | default = "desktop"; 15 | }; 16 | net.ifaces = lib.mkOption { 17 | type = with lib.types; listOf str; 18 | description = "Available net interfaces."; 19 | example = [ 20 | "eno1" 21 | "wlp2s0" 22 | ]; 23 | default = [ "eth0" ]; 24 | }; 25 | mount.points = lib.mkOption { 26 | type = with lib.types; listOf path; 27 | description = "Available mount points."; 28 | example = [ 29 | "/" 30 | "/mnt/backup" 31 | ]; 32 | default = 33 | if (config ? fileSystems) then 34 | (lib.lists.subtractLists [ 35 | "/boot" 36 | "/tmp" 37 | "/nix" 38 | "/bin" 39 | "/usr/bin" 40 | ] (lib.mapAttrsToList (n: _: n) config.fileSystems)) 41 | else 42 | [ "/" ]; 43 | }; 44 | media.directory = lib.mkOption { 45 | type = lib.types.path; 46 | description = "Shared media directory."; 47 | example = "/mnt/media"; 48 | default = "/media"; 49 | }; 50 | }; 51 | } 52 | -------------------------------------------------------------------------------- /actions/update-flakes-after.nix: -------------------------------------------------------------------------------- 1 | let 2 | steps = import ./steps.nix; 3 | constants = import ./constants.nix; 4 | utils = import ./utils.nix; 5 | in 6 | with constants; 7 | with utils; 8 | { 9 | name = "update-flakes-after"; 10 | on = { 11 | workflow_run = { 12 | workflows = [ "update-flakes" ]; 13 | types = [ "completed" ]; 14 | }; 15 | workflow_dispatch = null; 16 | }; 17 | inherit (steps) concurrency; 18 | 19 | jobs = { 20 | update-flakes-aarch64-darwin = { 21 | inherit (macos) runs-on; 22 | "if" = escapeGhVar "github.event.workflow_run.conclusion == 'success'"; 23 | steps = 24 | with steps; 25 | withSharedSteps [ 26 | (buildHomeManagerConfigurations { inherit (home-manager.aarch64-darwin) hostNames; }) 27 | (buildNixDarwinConfigurations { inherit (nix-darwin.aarch64-darwin) hostNames; }) 28 | ]; 29 | }; 30 | 31 | update-flakes-aarch64-linux = { 32 | inherit (ubuntu-arm) runs-on; 33 | "if" = escapeGhVar "github.event.workflow_run.conclusion == 'success'"; 34 | steps = 35 | with steps; 36 | withSharedSteps [ 37 | freeDiskSpaceStep 38 | (buildHomeManagerConfigurations { inherit (home-manager.aarch64-linux) hostNames; }) 39 | (buildNixOSConfigurations { inherit (nixos.aarch64-linux) hostNames; }) 40 | ]; 41 | }; 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /modules/nixos/desktop/default.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | { 4 | imports = [ 5 | ./audio.nix 6 | ./fonts.nix 7 | ./kde.nix 8 | ./locale.nix 9 | ./plymouth.nix 10 | ./tailscale.nix 11 | ./wireless.nix 12 | ]; 13 | 14 | options.nixos.desktop.enable = lib.mkEnableOption "desktop config" // { 15 | default = builtins.any (x: config.device.type == x) [ 16 | "desktop" 17 | "laptop" 18 | "steam-machine" 19 | ]; 20 | }; 21 | 22 | config = lib.mkIf config.nixos.desktop.enable { 23 | nixos.home.extraModules = { 24 | home-manager.desktop.enable = true; 25 | }; 26 | 27 | programs.gnome-disks.enable = true; 28 | 29 | # Increase file handler limit 30 | security.pam.loginLimits = [ 31 | { 32 | domain = "*"; 33 | type = "-"; 34 | item = "nofile"; 35 | value = "524288"; 36 | } 37 | ]; 38 | 39 | systemd = { 40 | settings.Manager = { 41 | # Reduce default service stop timeouts for faster shutdown 42 | DefaultTimeoutStopSec = lib.mkDefault "15s"; 43 | }; 44 | services."user@".serviceConfig = { 45 | # Reduce default service stop for User services 46 | TimeoutStopSec = lib.mkDefault "15s"; 47 | }; 48 | }; 49 | 50 | services = { 51 | dbus.implementation = "broker"; 52 | flatpak.enable = true; 53 | }; 54 | }; 55 | } 56 | -------------------------------------------------------------------------------- /hosts/nixos/blackrockshooter-nixos/hardware-configuration.nix: -------------------------------------------------------------------------------- 1 | # Do not modify this file! It was generated by ‘nixos-generate-config’ 2 | # and may be overwritten by future invocations. Please make changes 3 | # to /etc/nixos/configuration.nix instead. 4 | { 5 | config, 6 | lib, 7 | modulesPath, 8 | ... 9 | }: 10 | 11 | { 12 | imports = [ 13 | (modulesPath + "/installer/scan/not-detected.nix") 14 | ]; 15 | 16 | boot.initrd.availableKernelModules = [ 17 | "nvme" 18 | "xhci_pci" 19 | "ahci" 20 | "usb_storage" 21 | "uas" 22 | "usbhid" 23 | "sd_mod" 24 | ]; 25 | boot.initrd.kernelModules = [ ]; 26 | boot.kernelModules = [ "kvm-amd" ]; 27 | boot.extraModulePackages = [ ]; 28 | 29 | # Enables DHCP on each ethernet and wireless interface. In case of scripted networking 30 | # (the default) this is the recommended approach. When using systemd-networkd it's 31 | # still possible to use this option, but it's recommended to use it in conjunction 32 | # with explicit per-interface declarations with `networking.interfaces..useDHCP`. 33 | networking.useDHCP = lib.mkDefault true; 34 | # networking.interfaces.enp8s0.useDHCP = lib.mkDefault true; 35 | # networking.interfaces.wlp7s0.useDHCP = lib.mkDefault true; 36 | 37 | nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; 38 | hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; 39 | } 40 | -------------------------------------------------------------------------------- /modules/shared/theme/fonts.nix: -------------------------------------------------------------------------------- 1 | { pkgs, lib, ... }: 2 | 3 | let 4 | fontType = lib.types.submodule { 5 | options = { 6 | package = lib.mkOption { 7 | type = with lib.types; nullOr package; 8 | description = "Font package."; 9 | }; 10 | name = lib.mkOption { 11 | type = with lib.types; either (listOf str) str; 12 | description = "Font name."; 13 | }; 14 | }; 15 | }; 16 | in 17 | { 18 | options.theme.fonts = { 19 | dpi = lib.mkOption { 20 | type = lib.types.int; 21 | description = "Font dpi."; 22 | default = 135; 23 | }; 24 | 25 | gui = lib.mkOption { 26 | type = lib.types.nullOr fontType; 27 | description = "GUI font."; 28 | default = { 29 | package = pkgs.roboto; 30 | name = "Roboto"; 31 | }; 32 | }; 33 | 34 | icons = lib.mkOption { 35 | type = lib.types.nullOr fontType; 36 | description = "Icons font."; 37 | default = { 38 | package = pkgs.font-awesome_6; 39 | name = [ 40 | "Font Awesome 6 Brands" 41 | "Font Awesome 6 Free Solid" 42 | ]; 43 | }; 44 | }; 45 | 46 | symbols = lib.mkOption { 47 | type = lib.types.nullOr fontType; 48 | description = "Symbols font."; 49 | default = { 50 | package = pkgs.nerd-fonts.hack; 51 | name = "Hack Nerd Font Mono"; 52 | }; 53 | }; 54 | }; 55 | } 56 | -------------------------------------------------------------------------------- /actions/build-and-cache.nix: -------------------------------------------------------------------------------- 1 | let 2 | steps = import ./steps.nix; 3 | constants = import ./constants.nix; 4 | in 5 | with constants; 6 | { 7 | name = "build-and-cache"; 8 | on = [ 9 | "push" 10 | "workflow_dispatch" 11 | ]; 12 | inherit (steps) concurrency; 13 | 14 | jobs = { 15 | build-aarch64-linux = { 16 | inherit (ubuntu-arm) runs-on; 17 | steps = 18 | with steps; 19 | withSharedSteps [ 20 | freeDiskSpaceStep 21 | (buildHomeManagerConfigurations { inherit (home-manager.aarch64-linux) hostNames; }) 22 | (buildNixOSConfigurations { inherit (nixos.aarch64-linux) hostNames; }) 23 | ]; 24 | }; 25 | 26 | build-x86_64-linux = { 27 | inherit (ubuntu) runs-on; 28 | steps = 29 | with steps; 30 | withSharedSteps [ 31 | freeDiskSpaceStep 32 | (buildHomeManagerConfigurations { inherit (home-manager.x86_64-linux) hostNames; }) 33 | (buildNixOSConfigurations { inherit (nixos.x86_64-linux) hostNames; }) 34 | ]; 35 | }; 36 | 37 | build-aarch64-darwin = { 38 | inherit (macos) runs-on; 39 | steps = 40 | with steps; 41 | withSharedSteps [ 42 | (buildHomeManagerConfigurations { inherit (home-manager.aarch64-darwin) hostNames; }) 43 | (buildNixDarwinConfigurations { inherit (nix-darwin.aarch64-darwin) hostNames; }) 44 | ]; 45 | }; 46 | }; 47 | } 48 | -------------------------------------------------------------------------------- /modules/home-manager/crostini.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | { 4 | options.home-manager.crostini.enable = lib.mkEnableOption "Crostini (ChromeOS) config"; 5 | 6 | config = lib.mkIf config.home-manager.crostini.enable { 7 | # https://nixos.wiki/wiki/Installing_Nix_on_Crostini 8 | xdg.configFile."systemd/user/cros-garcon.service.d/override.conf".text = 9 | lib.generators.toINI { listsAsDuplicateKeys = true; } 10 | { 11 | Service = { 12 | Environment = [ 13 | "PATH=${ 14 | lib.concatStringsSep ":" [ 15 | "${config.home.profileDirectory}/bin" 16 | "/usr/local/sbin" 17 | "/usr/local/bin" 18 | "/usr/local/games" 19 | "/usr/sbin" 20 | "/usr/bin" 21 | "/usr/games" 22 | "/sbin" 23 | "/bin" 24 | ] 25 | }" 26 | "XDG_DATA_DIRS=${ 27 | lib.concatStringsSep ":" [ 28 | "${config.home.profileDirectory}/share" 29 | "%h/.local/share" 30 | "%h/.local/share/flatpak/exports/share" 31 | "/var/lib/flatpak/exports/share" 32 | "/usr/local/share" 33 | "/usr/share" 34 | ] 35 | }" 36 | ]; 37 | }; 38 | }; 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /modules/nixos/desktop/kde.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.nixos.desktop.kde; 10 | in 11 | { 12 | options.nixos.desktop.kde = { 13 | enable = lib.mkEnableOption "KDE config" // { 14 | default = config.device.type == "steam-machine"; 15 | }; 16 | sddm.enable = lib.mkEnableOption "KDE config" // { 17 | default = config.device.type != "steam-machine"; 18 | }; 19 | }; 20 | 21 | config = lib.mkIf cfg.enable { 22 | environment.systemPackages = 23 | with pkgs; 24 | [ 25 | kdePackages.kcalc 26 | kdePackages.kcharselect 27 | kdePackages.kclock 28 | kdePackages.kcolorchooser 29 | kdePackages.kolourpaint 30 | kdePackages.ksystemlog 31 | kdiskmark 32 | ] 33 | ++ lib.optionals cfg.sddm.enable [ 34 | kdePackages.sddm-kcm 35 | ] 36 | ++ lib.optionals config.services.flatpak.enable [ 37 | kdePackages.discover 38 | ] 39 | ++ lib.optionals config.services.smartd.enable [ 40 | kdePackages.plasma-disks 41 | ]; 42 | 43 | programs.kdeconnect.enable = true; 44 | 45 | services = { 46 | desktopManager.plasma6.enable = true; 47 | displayManager = { 48 | defaultSession = "plasma"; 49 | sddm = { 50 | inherit (cfg.sddm) enable; 51 | wayland.enable = cfg.sddm.enable; 52 | }; 53 | }; 54 | }; 55 | }; 56 | } 57 | -------------------------------------------------------------------------------- /hosts/nixos/sankyuu-nixos/hardware-configuration.nix: -------------------------------------------------------------------------------- 1 | # Do not modify this file! It was generated by ‘nixos-generate-config’ 2 | # and may be overwritten by future invocations. Please make changes 3 | # to /etc/nixos/configuration.nix instead. 4 | { 5 | config, 6 | lib, 7 | modulesPath, 8 | ... 9 | }: 10 | 11 | { 12 | imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; 13 | 14 | boot.initrd.availableKernelModules = [ 15 | "nvme" 16 | "ehci_pci" 17 | "xhci_pci" 18 | "usbhid" 19 | "rtsx_pci_sdmmc" 20 | ]; 21 | boot.initrd.kernelModules = [ "dm-snapshot" ]; 22 | boot.kernelModules = [ "kvm-amd" ]; 23 | boot.extraModulePackages = [ ]; 24 | 25 | # Enables DHCP on each ethernet and wireless interface. In case of scripted networking 26 | # (the default) this is the recommended approach. When using systemd-networkd it's 27 | # still possible to use this option, but it's recommended to use it in conjunction 28 | # with explicit per-interface declarations with `networking.interfaces..useDHCP`. 29 | networking.useDHCP = lib.mkDefault true; 30 | # networking.interfaces.enp2s0f0.useDHCP = lib.mkDefault true; 31 | # networking.interfaces.enp5s0.useDHCP = lib.mkDefault true; 32 | # networking.interfaces.enp7s0f3u2i1.useDHCP = lib.mkDefault true; 33 | # networking.interfaces.wlp3s0.useDHCP = lib.mkDefault true; 34 | 35 | nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; 36 | hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; 37 | } 38 | -------------------------------------------------------------------------------- /modules/home-manager/editor/emacs/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | flake, 3 | config, 4 | lib, 5 | pkgs, 6 | ... 7 | }: 8 | 9 | let 10 | emacs = config.programs.doom-emacs.finalEmacsPackage; 11 | in 12 | { 13 | imports = [ flake.inputs.nix-doom-emacs-unstraightened.homeModule ]; 14 | 15 | options.home-manager.editor.emacs.enable = lib.mkEnableOption "Emacs config" // { 16 | default = config.home-manager.editor.enable && config.home-manager.desktop.enable; 17 | }; 18 | 19 | config = lib.mkIf config.home-manager.editor.emacs.enable { 20 | home = { 21 | packages = with pkgs; [ 22 | (run-bg-alias "em" "${lib.getExe emacs}") 23 | (writeShellScriptBin "et" "${lib.getExe emacs} -nw $@") 24 | # fonts used in the config 25 | emacs-all-the-icons-fonts 26 | fira-code 27 | hack-font 28 | noto-fonts 29 | ]; 30 | }; 31 | 32 | programs.doom-emacs = { 33 | enable = true; 34 | doomDir = ./doom-emacs; 35 | 36 | emacs = 37 | with pkgs; 38 | if stdenv.isDarwin then 39 | emacs30 40 | else 41 | emacs30-pgtk.overrideAttrs (old: { 42 | patches = (old.patches or [ ]) ++ [ ./disable_pgtk_display_x_warning.patch ]; 43 | }); 44 | 45 | extraPackages = 46 | epkgs: with epkgs; [ 47 | treesit-grammars.with-all-grammars 48 | vterm 49 | ]; 50 | 51 | extraBinPackages = with pkgs; [ 52 | fd 53 | findutils 54 | ripgrep 55 | ]; 56 | }; 57 | }; 58 | } 59 | -------------------------------------------------------------------------------- /modules/nixos/games/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | let 9 | inherit (config.nixos.home) username; 10 | cfg = config.nixos.games; 11 | in 12 | { 13 | imports = [ 14 | ./jovian.nix 15 | ./osu.nix 16 | ./ratbag.nix 17 | ./retroarch.nix 18 | ./steam.nix 19 | ]; 20 | 21 | options.nixos.games = { 22 | enable = lib.mkEnableOption "games config" // { 23 | default = config.device.type == "steam-machine"; 24 | }; 25 | }; 26 | 27 | config = lib.mkIf cfg.enable { 28 | # https://fedoraproject.org/wiki/Changes/IncreaseVmMaxMapCount 29 | # https://pagure.io/fesco/issue/2993#comment-859763 30 | boot.kernel.sysctl."vm.max_map_count" = 1048576; 31 | 32 | environment.systemPackages = with pkgs; [ 33 | goverlay 34 | mangohud 35 | (bottles.override { 36 | removeWarningPopup = true; 37 | }) 38 | ]; 39 | 40 | programs.gamemode = { 41 | enable = true; 42 | settings = { 43 | general = { 44 | softrealtime = "auto"; 45 | renice = 10; 46 | }; 47 | custom = { 48 | start = "${lib.getExe pkgs.libnotify} 'GameMode started'"; 49 | end = "${lib.getExe pkgs.libnotify} 'GameMode ended'"; 50 | }; 51 | }; 52 | }; 53 | 54 | users.users.${username}.extraGroups = [ "gamemode" ]; 55 | 56 | hardware = { 57 | graphics.enable32Bit = true; 58 | # Alternative driver for Xbox One/Series S/Series X controllers 59 | xone.enable = true; 60 | }; 61 | }; 62 | } 63 | -------------------------------------------------------------------------------- /modules/home-manager/editor/helix.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | { 9 | options.home-manager.editor.helix.enable = lib.mkEnableOption "Helix editor config" // { 10 | default = config.home-manager.editor.enable; 11 | }; 12 | 13 | config = lib.mkIf config.home-manager.editor.helix.enable { 14 | programs.helix = { 15 | enable = true; 16 | package = pkgs.evil-helix; 17 | 18 | settings = { 19 | theme = "catppuccin_mocha"; 20 | 21 | editor = { 22 | # Force true-color for e.g., crostini's terminal 23 | true-color = true; 24 | soft-wrap.enable = true; 25 | statusline = { 26 | left = [ 27 | "mode" 28 | "spinner" 29 | ]; 30 | center = [ "file-name" ]; 31 | right = [ 32 | "diagnostics" 33 | "selections" 34 | "position" 35 | "file-encoding" 36 | "file-line-ending" 37 | "file-type" 38 | ]; 39 | separator = "│"; 40 | mode.normal = "NORMAL"; 41 | mode.insert = "INSERT"; 42 | mode.select = "SELECT"; 43 | }; 44 | }; 45 | 46 | keys = { 47 | normal = { 48 | space.space = "file_picker"; 49 | C-h = "select_prev_sibling"; 50 | C-j = "shrink_selection"; 51 | C-k = "expand_selection"; 52 | C-l = "select_next_sibling"; 53 | }; 54 | }; 55 | }; 56 | }; 57 | }; 58 | } 59 | -------------------------------------------------------------------------------- /modules/shared/helpers/mk-home-module.nix: -------------------------------------------------------------------------------- 1 | prefix: 2 | { 3 | config, 4 | lib, 5 | libEx, 6 | flake, 7 | ... 8 | }: 9 | let 10 | cfg = config.${prefix}.home; 11 | cfgHome = config.home-manager.users.${cfg.username}; 12 | in 13 | { 14 | options.${prefix}.home = { 15 | enable = lib.mkEnableOption "home config" // { 16 | default = true; 17 | }; 18 | restoreBackups = lib.mkEnableOption "restore backup files before activation"; 19 | username = lib.mkOption { 20 | description = "Main username."; 21 | type = lib.types.str; 22 | default = "thiagoko"; 23 | }; 24 | extraModules = lib.mkOption { 25 | description = "Extra modules to import."; 26 | type = with lib.types; coercedTo attrs (x: [ x ]) (listOf attrs); 27 | default = [ ]; 28 | }; 29 | }; 30 | 31 | config = lib.mkIf cfg.enable { 32 | # Home-Manager standalone already adds home-manager to PATH, so we 33 | # are adding here only for NixOS 34 | environment.systemPackages = [ 35 | cfgHome.programs.home-manager.package 36 | ]; 37 | 38 | home-manager = rec { 39 | backupFileExtension = "hm-backup"; 40 | useUserPackages = true; 41 | useGlobalPkgs = true; 42 | users.${cfg.username} = { 43 | inherit (config) meta device theme; 44 | imports = [ flake.outputs.homeModules.default ] ++ cfg.extraModules; 45 | home-manager = { 46 | inherit (config.networking) hostName; 47 | meta.restoreBackups = lib.mkIf cfg.restoreBackups { inherit backupFileExtension; }; 48 | }; 49 | }; 50 | extraSpecialArgs = { inherit flake libEx; }; 51 | }; 52 | }; 53 | } 54 | -------------------------------------------------------------------------------- /hosts/nixos/zachune-nixos/default.nix: -------------------------------------------------------------------------------- 1 | # Edit this configuration file to define what should be installed on 2 | # your system. Help is available in the configuration.nix(5) man page 3 | # and in the NixOS manual (accessible by running ‘nixos-help’). 4 | 5 | { modulesPath, flake, ... }@inputs: 6 | 7 | let 8 | oci-common = import "${modulesPath}/virtualisation/oci-common.nix" { 9 | inherit (inputs) pkgs lib config; 10 | }; 11 | in 12 | { 13 | imports = [ 14 | # Include the results of the hardware scan. 15 | ./hardware-configuration.nix 16 | flake.inputs.disko.nixosModules.disko 17 | ] 18 | ++ oci-common.imports; 19 | 20 | boot = { 21 | inherit (oci-common.boot) kernelParams; 22 | }; 23 | 24 | disko.devices = import ./disk-config.nix; 25 | 26 | device = { 27 | net.ifaces = [ "ens3" ]; 28 | type = "server"; 29 | }; 30 | 31 | nixos = { 32 | server = { 33 | iperf3.enable = true; 34 | ssh = { 35 | enable = true; 36 | root.enableLogin = true; 37 | }; 38 | tailscale.enable = true; 39 | }; 40 | }; 41 | 42 | # Use the systemd-boot EFI boot loader. 43 | boot.loader.systemd-boot.enable = true; 44 | boot.loader.efi.canTouchEfiVariables = true; 45 | 46 | networking = { 47 | inherit (oci-common.networking) timeServers; 48 | }; 49 | 50 | time.timeZone = "Europe/Dublin"; 51 | 52 | # This value determines the NixOS release with which your system is to be 53 | # compatible, in order to avoid breaking some software such as database 54 | # servers. You should change this only after NixOS release notes say you 55 | # should. 56 | system.stateVersion = "24.05"; # Did you read the comment? 57 | } 58 | -------------------------------------------------------------------------------- /modules/home-manager/window-manager/x11/screen-locker.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | { 9 | options.home-manager.window-manager.x11.screen-locker.enable = 10 | lib.mkEnableOption "screen-locker config" 11 | // { 12 | default = config.home-manager.window-manager.x11.enable; 13 | }; 14 | 15 | config = lib.mkIf config.home-manager.window-manager.x11.screen-locker.enable { 16 | services.screen-locker = { 17 | enable = true; 18 | inactiveInterval = 10; 19 | lockCmd = 20 | with config.theme.fonts; 21 | toString ( 22 | pkgs.writeShellScript "lock-screen" '' 23 | export XSECURELOCK_FORCE_GRAB=1 24 | export XSECURELOCK_BLANK_DPMS_STATE="off" 25 | export XSECURELOCK_DATETIME_FORMAT="%H:%M:%S - %a %d/%m" 26 | export XSECURELOCK_SHOW_DATETIME=1 27 | export XSECURELOCK_SHOW_HOSTNAME=0 28 | export XSECURELOCK_SHOW_USERNAME=0 29 | export XSECURELOCK_FONT="${gui.name}:style=Regular" 30 | 31 | exec ${lib.getExe pkgs.xsecurelock} $@ 32 | '' 33 | ); 34 | # Use xss-lock instead 35 | xautolock.enable = false; 36 | xss-lock = { 37 | extraOptions = 38 | let 39 | notify = pkgs.writeShellScript "notify" '' 40 | ${lib.getExe' pkgs.dunst "dunstify"} -t 30000 "30 seconds to lock" 41 | ''; 42 | in 43 | [ 44 | "--notifier ${notify}" 45 | "--transfer-sleep-lock" 46 | "--session $XDG_SESSION_ID" 47 | ]; 48 | screensaverCycle = 600; 49 | }; 50 | }; 51 | }; 52 | } 53 | -------------------------------------------------------------------------------- /docs/non-nixos.md: -------------------------------------------------------------------------------- 1 | # Non-NixOS setup 2 | 3 | List of configuration that needs to be done manually in non-NixOS systems. 4 | 5 | ## Nix config 6 | 7 | In `/etc/nix/nix.conf` file: 8 | 9 | ``` 10 | build-users-group = nixbld 11 | experimental-features = nix-command flakes 12 | trusted-users = [ root @sudo ] # or @wheel/@admin 13 | builders-use-substitutes = true 14 | ``` 15 | 16 | ### Restart nix-daemon (macOS) 17 | 18 | After changing the `/etc/nix/nix.conf` file, you will need to restart the 19 | `nix-daemon`: 20 | 21 | ``` 22 | # launchctl kickstart -k system/org.nixos.nix-daemon 23 | ``` 24 | 25 | ## (Optional) Setup remote builders 26 | 27 | [See](https://nixos.org/manual/nix/stable/advanced-topics/distributed-builds.html) 28 | for more information about what remote builders are. 29 | 30 | To setup it: 31 | 32 | ```console 33 | $ nix eval --raw .#nixosConfigurations.sankyuu-nixos.config.environment.etc."nix/machines".text | sudo tee -a /etc/nix/machines 34 | ``` 35 | 36 | This will populate `/etc/nix/machines` file. 37 | 38 | Needs Tailscale configured. You also may need to do: 39 | 40 | ```console 41 | # nix store ping --store ssh-ng://100.97.139.21 42 | Store URL: ssh-ng://100.97.139.21 43 | The authenticity of host '100.97.139.21 (100.97.139.21)' can't be established. 44 | ED25519 key fingerprint is SHA256:JLZRJZARsvg2jtUYuS7+sTx8+FcEICsSj3vUKTHh9lM. 45 | This key is not known by any other names. 46 | Are you sure you want to continue connecting (yes/no/[fingerprint])? yes 47 | Warning: Permanently added '100.97.139.21' (ED25519) to the list of known hosts. 48 | Version: 2.18.4 49 | Trusted: 1 50 | ``` 51 | 52 | As `root`, because you need to trust the host certificates in the same user 53 | that the `nix-daemon` is running. 54 | -------------------------------------------------------------------------------- /overlays/default.nix: -------------------------------------------------------------------------------- 1 | { inputs, outputs, ... }: 2 | final: prev: 3 | 4 | let 5 | inherit (prev.stdenv.hostPlatform) system; 6 | in 7 | { 8 | # namespaces 9 | libEx = outputs.lib; 10 | 11 | # custom packages 12 | inherit (inputs.gh-gfm-preview.packages.${system}) gh-gfm-preview; 13 | inherit (inputs.gitk-go.packages.${system}) gitk-go; 14 | inherit (inputs.nix-alien.packages.${system}) nix-alien; 15 | 16 | neovim-standalone = 17 | let 18 | hostName = "neovim-standalone"; 19 | hm = outputs.lib.mkHomeConfig { 20 | inherit hostName system; 21 | configuration = { 22 | home-manager = { 23 | cli.icons.enable = false; 24 | dev = { 25 | enable = true; 26 | nix.enable = true; 27 | }; 28 | editor.neovim = { 29 | enable = true; 30 | lsp.enable = true; 31 | treeSitter.enable = true; 32 | }; 33 | }; 34 | home.stateVersion = "25.11"; 35 | }; 36 | }; 37 | in 38 | hm.homeConfigurations.${hostName}.config.home-manager.editor.neovim.standalonePackage; 39 | 40 | nix-cleanup = prev.callPackage ../packages/nix-cleanup { }; 41 | 42 | nixos-cleanup = final.nix-cleanup.override { isNixOS = true; }; 43 | 44 | darwin-cleanup = final.nix-cleanup.override { isNixDarwin = true; }; 45 | 46 | mkWallpaperImgur = prev.callPackage ../packages/wallpapers/mkWallpaperImgur.nix { }; 47 | 48 | nix-whereis = prev.callPackage ../packages/nix-whereis { }; 49 | 50 | run-bg-alias = name: command: prev.callPackage ../packages/run-bg-alias { inherit name command; }; 51 | 52 | wallpapers = final.callPackage ../packages/wallpapers { }; 53 | } 54 | -------------------------------------------------------------------------------- /modules/home-manager/window-manager/theme/qt.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | lib, 5 | ... 6 | }: 7 | 8 | { 9 | options.home-manager.window-manager.theme.qt.enable = lib.mkEnableOption "Qt theme config" // { 10 | default = config.home-manager.window-manager.theme.enable; 11 | }; 12 | 13 | config = lib.mkIf config.home-manager.window-manager.theme.qt.enable { 14 | qt = { 15 | enable = true; 16 | platformTheme.name = "qtct"; 17 | style.name = "kvantum"; 18 | }; 19 | 20 | xdg.configFile = { 21 | "Kvantum/kvantum.kvconfig".text = lib.generators.toINI { } { 22 | General.theme = "Nordic-bluish-solid"; 23 | }; 24 | "Kvantum" = { 25 | source = "${pkgs.nordic}/share/Kvantum"; 26 | recursive = true; 27 | }; 28 | "qt5ct/qt5ct.conf".text = lib.generators.toINI { } { 29 | Appearance = { 30 | style = "kvantum-dark"; 31 | icon_theme = config.gtk.iconTheme.name; 32 | standard_dialogs = "gtk3"; 33 | }; 34 | Interface = { 35 | activate_item_on_single_click = 0; 36 | double_click_interval = 400; 37 | dialog_buttons_have_icons = 1; 38 | wheel_scroll_lines = 3; 39 | }; 40 | Fonts = { 41 | # Noto Sans Mono 10 42 | fixed = ''@Variant(\0\0\0@\0\0\0\x1c\0N\0o\0t\0o\0 \0S\0\x61\0n\0s\0 \0M\0o\0n\0o@$\0\0\0\0\0\0\xff\xff\xff\xff\x5\x1\0\x32\x10)''; 43 | # Noto Sans 10 44 | general = ''@Variant(\0\0\0@\0\0\0\x12\0N\0o\0t\0o\0 \0S\0\x61\0n\0s@$\0\0\0\0\0\0\xff\xff\xff\xff\x5\x1\0\x32\x10)''; 45 | }; 46 | }; 47 | "qt6ct/qt6ct.conf".text = config.xdg.configFile."qt5ct/qt5ct.conf".text; 48 | }; 49 | }; 50 | } 51 | -------------------------------------------------------------------------------- /modules/home-manager/cli/yazi.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | flake, 5 | ... 6 | }: 7 | 8 | let 9 | enableIcons = config.home-manager.cli.icons.enable; 10 | cfg = config.home-manager.cli.yazi; 11 | in 12 | { 13 | options.home-manager.cli.yazi = { 14 | enable = lib.mkEnableOption "yazi config" // { 15 | default = config.home-manager.cli.enable; 16 | }; 17 | }; 18 | 19 | config = lib.mkIf cfg.enable { 20 | home.packages = lib.optionals enableIcons [ 21 | config.theme.fonts.symbols.package 22 | ]; 23 | 24 | programs.yazi = { 25 | enable = true; 26 | shellWrapperName = "yy"; 27 | enableZshIntegration = true; 28 | flavors = 29 | let 30 | flavors = flake.inputs.yazi-flavors; 31 | in 32 | { 33 | catppuccin-frappe = "${flavors}/catppuccin-frappe.yazi"; 34 | catppuccin-latte = "${flavors}/catppuccin-latte.yazi"; 35 | catppuccin-macchiato = "${flavors}/catppuccin-macchiato.yazi"; 36 | catppuccin-mocha = "${flavors}/catppuccin-mocha.yazi"; 37 | }; 38 | theme = { 39 | flavor = { 40 | use = "catppuccin-macchiato"; 41 | }; 42 | # https://yazi-rs.github.io/docs/faq/#dont-like-nerd-fonts 43 | icon = lib.mkIf (!enableIcons) { 44 | globs = [ ]; 45 | dirs = [ ]; 46 | files = [ ]; 47 | exts = [ ]; 48 | conds = [ ]; 49 | }; 50 | status = lib.mkIf (!enableIcons) { 51 | sep_left = { 52 | open = ""; 53 | close = ""; 54 | }; 55 | sep_right = { 56 | open = ""; 57 | close = ""; 58 | }; 59 | }; 60 | }; 61 | }; 62 | }; 63 | } 64 | -------------------------------------------------------------------------------- /hosts/nixos/sankyuu-nixos/disk-config.nix: -------------------------------------------------------------------------------- 1 | { 2 | disko.devices = { 3 | disk = { 4 | main = { 5 | type = "disk"; 6 | device = "/dev/disk/by-id/nvme-SKHynix_HFS512GD9TNI-L2B0B_CD0BN57411010BG1N"; 7 | content = { 8 | type = "gpt"; 9 | partitions = { 10 | ESP = { 11 | size = "512M"; 12 | type = "EF00"; 13 | content = { 14 | type = "filesystem"; 15 | format = "vfat"; 16 | mountpoint = "/boot"; 17 | mountOptions = [ "umask=0077" ]; 18 | }; 19 | }; 20 | luks = { 21 | size = "100%"; 22 | content = { 23 | type = "luks"; 24 | name = "encrypted"; 25 | extraOpenArgs = [ ]; 26 | settings.allowDiscards = true; 27 | content = { 28 | type = "lvm_pv"; 29 | vg = "pool"; 30 | }; 31 | }; 32 | }; 33 | }; 34 | }; 35 | }; 36 | }; 37 | lvm_vg = { 38 | pool = { 39 | type = "lvm_vg"; 40 | lvs = { 41 | root = { 42 | size = "100%"; 43 | content = { 44 | type = "filesystem"; 45 | format = "xfs"; 46 | mountpoint = "/"; 47 | mountOptions = [ "defaults" ]; 48 | }; 49 | }; 50 | swap = { 51 | size = "16G"; 52 | content = { 53 | type = "swap"; 54 | discardPolicy = "both"; 55 | resumeDevice = true; 56 | }; 57 | }; 58 | }; 59 | }; 60 | }; 61 | }; 62 | } 63 | -------------------------------------------------------------------------------- /hosts/nixos/blackrockshooter-nixos/disk-config.nix: -------------------------------------------------------------------------------- 1 | { 2 | disko.devices = { 3 | disk = { 4 | main = { 5 | type = "disk"; 6 | device = "/dev/disk/by-id/nvme-Samsung_SSD_990_EVO_Plus_2TB_S7U7NU0Y846690X"; 7 | content = { 8 | type = "gpt"; 9 | partitions = { 10 | ESP = { 11 | size = "1024M"; 12 | type = "EF00"; 13 | content = { 14 | type = "filesystem"; 15 | format = "vfat"; 16 | mountpoint = "/boot"; 17 | mountOptions = [ "umask=0077" ]; 18 | }; 19 | }; 20 | luks = { 21 | size = "100%"; 22 | content = { 23 | type = "luks"; 24 | name = "encrypted"; 25 | extraOpenArgs = [ ]; 26 | settings.allowDiscards = true; 27 | content = { 28 | type = "lvm_pv"; 29 | vg = "pool"; 30 | }; 31 | }; 32 | }; 33 | }; 34 | }; 35 | }; 36 | }; 37 | lvm_vg = { 38 | pool = { 39 | type = "lvm_vg"; 40 | lvs = { 41 | root = { 42 | size = "100%"; 43 | content = { 44 | type = "filesystem"; 45 | format = "xfs"; 46 | mountpoint = "/"; 47 | mountOptions = [ "defaults" ]; 48 | }; 49 | }; 50 | swap = { 51 | size = "64G"; 52 | content = { 53 | type = "swap"; 54 | discardPolicy = "both"; 55 | resumeDevice = true; 56 | }; 57 | }; 58 | }; 59 | }; 60 | }; 61 | }; 62 | } 63 | -------------------------------------------------------------------------------- /hosts/nixos/hachune-nixos/default.nix: -------------------------------------------------------------------------------- 1 | # Edit this configuration file to define what should be installed on 2 | # your system. Help is available in the configuration.nix(5) man page 3 | # and in the NixOS manual (accessible by running ‘nixos-help’). 4 | 5 | { 6 | config, 7 | pkgs, 8 | flake, 9 | ... 10 | }: 11 | 12 | { 13 | imports = [ 14 | ./hardware-configuration.nix 15 | flake.inputs.hardware.nixosModules.common-cpu-amd 16 | flake.inputs.hardware.nixosModules.common-gpu-amd 17 | ]; 18 | 19 | device = { 20 | type = "desktop"; 21 | net.ifaces = [ "enp2s0f1" ]; 22 | media.directory = "/mnt/media/${config.nixos.home.username}"; 23 | }; 24 | 25 | nixos = { 26 | desktop.wireless.enable = false; 27 | laptop.tlp.enable = true; 28 | system.networkd.enable = true; 29 | server = { 30 | enable = true; 31 | iperf3.enable = true; 32 | plex.enable = true; 33 | rtorrent.enable = true; 34 | samba.enable = true; 35 | ssh.enable = true; 36 | tailscale.enable = true; 37 | duckdns-updater = { 38 | enable = true; 39 | certs.enable = true; 40 | domain = "hachune-nixos.duckdns.org"; 41 | }; 42 | }; 43 | }; 44 | 45 | # Use the systemd-boot EFI boot loader 46 | boot.loader.systemd-boot.enable = true; 47 | boot.loader.efi.canTouchEfiVariables = true; 48 | 49 | # Use ultrawide wallpaper 50 | theme.wallpaper.path = pkgs.wallpapers.hatsune-miku_stylized-ultrawide; 51 | 52 | # This value determines the NixOS release with which your system is to be 53 | # compatible, in order to avoid breaking some software such as database 54 | # servers. You should change this only after NixOS release notes say you 55 | # should. 56 | system.stateVersion = "24.05"; # Did you read the comment? 57 | } 58 | -------------------------------------------------------------------------------- /modules/home-manager/cli/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | lib, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.home-manager.cli; 10 | in 11 | { 12 | imports = [ 13 | ./btop.nix 14 | ./git.nix 15 | ./htop.nix 16 | ./irssi.nix 17 | ./jujutsu.nix 18 | ./nixpkgs.nix 19 | ./ssh 20 | ./tmux.nix 21 | ./yazi.nix 22 | ./zellij.nix 23 | ./zsh 24 | ]; 25 | 26 | options.home-manager.cli = { 27 | enable = lib.mkEnableOption "CLI config" // { 28 | default = true; 29 | }; 30 | # Do not forget to set 'Hack Nerd Mono Font' as the terminal font 31 | icons.enable = lib.mkEnableOption "terminal icons" // { 32 | default = config.home-manager.desktop.enable || config.home-manager.darwin.enable; 33 | }; 34 | }; 35 | 36 | config = lib.mkIf cfg.enable { 37 | home = { 38 | packages = with pkgs; [ 39 | _7zz 40 | bc 41 | bind.dnsutils 42 | curl 43 | dialog 44 | dos2unix 45 | dua 46 | each 47 | ffmpeg 48 | file 49 | hyperfine 50 | lsof 51 | mediainfo 52 | ouch 53 | page 54 | pv 55 | rlwrap 56 | tokei 57 | watch 58 | wget 59 | ]; 60 | 61 | shellAliases = { 62 | # For muscle memory... 63 | archive = "${lib.getExe pkgs.ouch} compress"; 64 | unarchive = "${lib.getExe pkgs.ouch} decompress"; 65 | lsarchive = "${lib.getExe pkgs.ouch} list"; 66 | ncdu = "${lib.getExe pkgs.dua} interactive"; 67 | sloccount = lib.getExe pkgs.tokei; 68 | }; 69 | }; 70 | 71 | programs = { 72 | aria2.enable = true; 73 | jq.enable = true; 74 | less.enable = true; 75 | ripgrep.enable = true; 76 | }; 77 | }; 78 | } 79 | -------------------------------------------------------------------------------- /modules/nixos/games/retroarch.nix: -------------------------------------------------------------------------------- 1 | { 2 | pkgs, 3 | lib, 4 | config, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.nixos.games.retroarch; 10 | finalPackage = 11 | if (cfg.cores == "all") then 12 | pkgs.retroarch-full 13 | else 14 | pkgs.retroarch.withCores ( 15 | cores: 16 | lib.pipe cores [ 17 | (lib.getAttrs cfg.cores) 18 | lib.attrValues 19 | ] 20 | ); 21 | in 22 | { 23 | options.nixos.games.retroarch = { 24 | enable = lib.mkEnableOption "RetroArch config"; 25 | cores = lib.mkOption { 26 | type = with lib.types; either (enum [ "all" ]) (listOf str); 27 | default = [ 28 | "beetle-lynx" 29 | "beetle-ngp" 30 | "beetle-pce-fast" 31 | "beetle-pcfx" 32 | "beetle-supergrafx" 33 | "beetle-wswan" 34 | "bsnes-hd" 35 | "fbneo" 36 | "flycast" 37 | "gambatte" 38 | "genesis-plus-gx" 39 | "melonds" 40 | "mgba" 41 | "mupen64plus" 42 | "neocd" 43 | "nestopia" 44 | "pcsx2" 45 | "ppsspp" 46 | "snes9x" 47 | "stella" 48 | "swanstation" 49 | "yabause" 50 | ]; 51 | description = "List of cores to include. Pass `all` to use `retroarchFull` instead."; 52 | }; 53 | finalPackage = lib.mkOption { 54 | type = lib.types.package; 55 | description = "Final package."; 56 | readOnly = true; 57 | }; 58 | }; 59 | 60 | config = lib.mkIf cfg.enable { 61 | nixos.games.retroarch.finalPackage = finalPackage; 62 | 63 | environment.systemPackages = [ finalPackage ]; 64 | 65 | services.xserver.desktopManager.retroarch = { 66 | inherit (config.nixos.games.retroarch) package; 67 | enable = true; 68 | }; 69 | }; 70 | } 71 | -------------------------------------------------------------------------------- /modules/home-manager/window-manager/wayland/fuzzel.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | let 4 | cfg = config.home-manager.window-manager.wayland.fuzzel; 5 | in 6 | { 7 | options.home-manager.window-manager.wayland.fuzzel.enable = lib.mkEnableOption "Fuzzel config" // { 8 | default = config.home-manager.window-manager.wayland.enable; 9 | }; 10 | 11 | config = lib.mkIf cfg.enable { 12 | programs.fuzzel = { 13 | enable = true; 14 | settings = with config.theme.fonts; { 15 | main = { 16 | inherit (config.home-manager.window-manager.default) terminal; 17 | font = "${gui.name}:style=regular:size=14"; 18 | icon-theme = config.gtk.iconTheme.name; 19 | lines = 15; 20 | horizontal-pad = 10; 21 | vertical-pad = 10; 22 | line-height = 28; 23 | }; 24 | colors = 25 | with config.theme.colors; 26 | let 27 | fixColor = color: "${lib.removePrefix "#" color}ff"; 28 | in 29 | { 30 | background = fixColor base00; 31 | border = fixColor base00; 32 | input = fixColor base05; 33 | placeholder = fixColor base05; 34 | prompt = fixColor base05; 35 | selection = fixColor base0D; 36 | selection-match = fixColor base08; 37 | selection-text = fixColor base00; 38 | text = fixColor base05; 39 | }; 40 | key-bindings = { 41 | # Unmap delete-line-forward since its Control+k mapping conflicts 42 | # with custom prev mapping, and also unmap delete-line-backward for 43 | # consistency 44 | delete-line-backward = "none"; 45 | delete-line-forward = "none"; 46 | prev = "Up Control+p Control+k"; 47 | next = "Down Control+n Control+j"; 48 | }; 49 | }; 50 | }; 51 | }; 52 | } 53 | -------------------------------------------------------------------------------- /modules/nixos/window-manager/wayland.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.nixos.window-manager.wayland; 10 | in 11 | { 12 | options.nixos.window-manager.wayland = { 13 | sway.enable = lib.mkEnableOption "Sway config" // { 14 | default = config.nixos.window-manager.enable; 15 | }; 16 | }; 17 | 18 | config = lib.mkMerge [ 19 | (lib.mkIf cfg.sway.enable { 20 | nixos.home.extraModules = { 21 | home-manager.window-manager.wayland.sway.enable = true; 22 | }; 23 | 24 | programs = { 25 | sway = { 26 | # Make Sway available for display managers and make things like swaylock work 27 | inherit (cfg.sway) enable; 28 | # Do not add this to display managers (we will add via UWSM) 29 | package = null; 30 | # Remove unnecessary packages from system-wide install (e.g.: foot) 31 | extraPackages = [ ]; 32 | }; 33 | uwsm = { 34 | enable = true; 35 | waylandCompositors.sway = lib.mkIf cfg.sway.enable { 36 | prettyName = "Sway"; 37 | comment = "Sway compositor managed by UWSM"; 38 | binPath = "/etc/profiles/per-user/${config.nixos.home.username}/bin/sway"; 39 | }; 40 | }; 41 | }; 42 | 43 | # https://github.com/NixOS/nixpkgs/pull/207842#issuecomment-1374906499 44 | security.pam.loginLimits = [ 45 | { 46 | domain = "@users"; 47 | item = "rtprio"; 48 | type = "-"; 49 | value = 1; 50 | } 51 | ]; 52 | 53 | # For sway screensharing 54 | # https://nixos.wiki/wiki/Firefox 55 | xdg.portal = lib.mkIf cfg.sway.enable { 56 | enable = true; 57 | extraPortals = with pkgs; [ xdg-desktop-portal-gtk ]; 58 | # Allow for screensharing in wlroots-based desktop 59 | wlr.enable = true; 60 | }; 61 | }) 62 | ]; 63 | } 64 | -------------------------------------------------------------------------------- /hosts/nixos/zatsune-nixos/default.nix: -------------------------------------------------------------------------------- 1 | # Edit this configuration file to define what should be installed on 2 | # your system. Help is available in the configuration.nix(5) man page 3 | # and in the NixOS manual (accessible by running ‘nixos-help’). 4 | 5 | { modulesPath, flake, ... }@inputs: 6 | 7 | let 8 | oci-common = import "${modulesPath}/virtualisation/oci-common.nix" { 9 | inherit (inputs) pkgs lib config; 10 | }; 11 | in 12 | { 13 | imports = [ 14 | # Include the results of the hardware scan. 15 | ./hardware-configuration.nix 16 | flake.inputs.disko.nixosModules.disko 17 | ] 18 | ++ oci-common.imports; 19 | 20 | boot = { 21 | inherit (oci-common.boot) kernelParams; 22 | }; 23 | 24 | disko.devices = import ./disk-config.nix; 25 | 26 | device = { 27 | net.ifaces = [ "enp0s6" ]; 28 | type = "server"; 29 | }; 30 | 31 | nixos = { 32 | # Has tons of memory and slow disk 33 | nix.tmpOnDisk = false; 34 | server = { 35 | iperf3.enable = true; 36 | ssh.enable = true; 37 | tailscale.enable = true; 38 | duckdns-updater = { 39 | enable = true; 40 | ipv6.enable = true; 41 | domain = "zatsune-nixos.duckdns.org"; 42 | onCalendar = "daily"; # fixed IP, mostly for health checking 43 | certs = { 44 | enable = true; 45 | useHttpServer = true; 46 | }; 47 | }; 48 | }; 49 | }; 50 | 51 | # Use the systemd-boot EFI boot loader. 52 | boot.loader.systemd-boot.enable = true; 53 | boot.loader.efi.canTouchEfiVariables = true; 54 | 55 | networking = { 56 | inherit (oci-common.networking) timeServers; 57 | }; 58 | 59 | # This value determines the NixOS release with which your system is to be 60 | # compatible, in order to avoid breaking some software such as database 61 | # servers. You should change this only after NixOS release notes say you 62 | # should. 63 | system.stateVersion = "24.05"; # Did you read the comment? 64 | } 65 | -------------------------------------------------------------------------------- /modules/home-manager/cli/ssh/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | { 9 | options.home-manager.cli.ssh.enable = lib.mkEnableOption "SSH config" // { 10 | default = config.home-manager.cli.enable; 11 | }; 12 | 13 | config = lib.mkIf config.home-manager.cli.ssh.enable { 14 | home.packages = with pkgs; [ mosh ]; 15 | 16 | programs = { 17 | ssh = { 18 | enable = true; 19 | enableDefaultConfig = false; 20 | package = with pkgs; lib.mkIf stdenv.isLinux openssh; 21 | 22 | includes = [ "local.d/*" ]; 23 | 24 | # We want to use the macOS keychain if available 25 | extraConfig = lib.optionalString config.home-manager.darwin.enable '' 26 | IgnoreUnknown UseKeychain 27 | UseKeychain yes 28 | ''; 29 | 30 | matchBlocks = { 31 | "*" = { 32 | addKeysToAgent = "yes"; 33 | compression = true; 34 | forwardAgent = true; 35 | serverAliveCountMax = 2; 36 | serverAliveInterval = 300; 37 | }; 38 | "github.com" = { 39 | identityFile = with config.home; "${homeDirectory}/.ssh/github"; 40 | }; 41 | "git.sr.ht" = { 42 | identityFile = with config.home; "${homeDirectory}/.ssh/sourcehut"; 43 | }; 44 | "gitlab.com" = { 45 | identityFile = with config.home; "${homeDirectory}/.ssh/gitlab"; 46 | }; 47 | }; 48 | }; 49 | 50 | zsh.initContent = 51 | # Checks if SSH_AUTH_SOCK is set and the socket is working, or start a 52 | # new ssh-agent otherwise (works in any OS) 53 | # bash 54 | '' 55 | source ${./ssh-agent.zsh} 56 | ''; 57 | }; 58 | 59 | # Start SSH agent via systemd (Linux-only) 60 | # Since this is a systemd user service, it stays between sessions 61 | services.ssh-agent.enable = lib.mkIf pkgs.stdenv.isLinux true; 62 | }; 63 | } 64 | -------------------------------------------------------------------------------- /modules/nixos/server/tailscale.nix: -------------------------------------------------------------------------------- 1 | { 2 | lib, 3 | config, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | let 9 | inherit (config.nixos.home) username; 10 | cfg = config.nixos.server.tailscale; 11 | serviceCfg = config.services.tailscale; 12 | in 13 | { 14 | options.nixos.server.tailscale = { 15 | enable = lib.mkEnableOption "Tailscale config (server side)"; 16 | net.ifaces = lib.mkOption { 17 | type = with lib.types; listOf str; 18 | description = "Net interfaces to enable transport layer offload."; 19 | default = config.device.net.ifaces; 20 | }; 21 | }; 22 | 23 | config = lib.mkIf cfg.enable { 24 | # Always allow traffic from your Tailscale network 25 | networking.firewall.trustedInterfaces = [ serviceCfg.interfaceName ]; 26 | 27 | services = { 28 | networkd-dispatcher = lib.mkIf (cfg.net.ifaces != [ ]) { 29 | enable = config.networking.useNetworkd; 30 | # https://tailscale.com/kb/1320/performance-best-practices#linux-optimizations-for-subnet-routers-and-exit-nodes 31 | rules."enable-transport-layer-offload" = { 32 | onState = [ "routable" ]; 33 | script = # bash 34 | '' 35 | #!${pkgs.runtimeShell} 36 | ${lib.concatStringsSep "\n" ( 37 | builtins.map ( 38 | iface: # bash 39 | '' 40 | if [[ "$IFACE" == "${iface}" ]]; then 41 | ${lib.getExe pkgs.ethtool} -K "${iface}" rx-udp-gro-forwarding on rx-gro-list off 42 | fi 43 | '') config.device.net.ifaces 44 | )} 45 | ''; 46 | }; 47 | }; 48 | tailscale = { 49 | enable = true; 50 | openFirewall = true; 51 | permitCertUid = toString config.users.users.${username}.uid; 52 | useRoutingFeatures = lib.mkDefault "server"; 53 | extraUpFlags = [ 54 | "--advertise-exit-node" 55 | "--ssh" 56 | ]; 57 | }; 58 | }; 59 | }; 60 | } 61 | -------------------------------------------------------------------------------- /hosts/nixos/hachune-nixos/hardware-configuration.nix: -------------------------------------------------------------------------------- 1 | # Do not modify this file! It was generated by ‘nixos-generate-config’ 2 | # and may be overwritten by future invocations. Please make changes 3 | # to /etc/nixos/configuration.nix instead. 4 | { 5 | config, 6 | lib, 7 | modulesPath, 8 | ... 9 | }: 10 | 11 | { 12 | imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; 13 | 14 | boot.initrd.availableKernelModules = [ 15 | "nvme" 16 | "xhci_pci" 17 | "ahci" 18 | "usb_storage" 19 | "usbhid" 20 | "sd_mod" 21 | ]; 22 | boot.initrd.kernelModules = [ ]; 23 | boot.kernelModules = [ "kvm-amd" ]; 24 | boot.extraModulePackages = [ ]; 25 | 26 | fileSystems."/" = { 27 | device = "/dev/disk/by-uuid/9d6c7c09-e47f-48e7-8bf0-eb6a56043e6c"; 28 | fsType = "xfs"; 29 | }; 30 | 31 | fileSystems."/boot" = { 32 | device = "/dev/disk/by-uuid/EF47-A813"; 33 | fsType = "vfat"; 34 | options = [ 35 | "fmask=0077" 36 | "dmask=0077" 37 | ]; 38 | }; 39 | 40 | fileSystems."/mnt/media" = { 41 | device = "/dev/disk/by-uuid/4d0bb878-e826-4a7e-9701-b2bcb4c29c2c"; 42 | fsType = "ext4"; 43 | }; 44 | 45 | swapDevices = [ { device = "/dev/disk/by-uuid/f5172467-1755-4560-a947-4c3566ffd6dc"; } ]; 46 | 47 | # Enables DHCP on each ethernet and wireless interface. In case of scripted networking 48 | # (the default) this is the recommended approach. When using systemd-networkd it's 49 | # still possible to use this option, but it's recommended to use it in conjunction 50 | # with explicit per-interface declarations with `networking.interfaces..useDHCP`. 51 | networking.useDHCP = lib.mkDefault true; 52 | # networking.interfaces.enp2s0f1.useDHCP = lib.mkDefault true; 53 | # networking.interfaces.enp4s0f3u1u2u1.useDHCP = lib.mkDefault true; 54 | # networking.interfaces.tailscale0.useDHCP = lib.mkDefault true; 55 | 56 | nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; 57 | hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; 58 | } 59 | -------------------------------------------------------------------------------- /modules/home-manager/window-manager/x11/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.home-manager.window-manager.x11; 10 | in 11 | { 12 | imports = [ 13 | ./autorandr 14 | ./i3 15 | ./i3status-rust.nix 16 | ./picom.nix 17 | ./rofi.nix 18 | ./screen-locker.nix 19 | ./wallpaper.nix 20 | ]; 21 | 22 | options.home-manager.window-manager.x11 = { 23 | enable = lib.mkEnableOption "x11 config" // { 24 | default = config.home-manager.window-manager.enable; 25 | }; 26 | nvidia = { 27 | enable = lib.mkEnableOption "NVIDIA config"; 28 | prime = { 29 | sync.enable = lib.mkEnableOption "enable NVIDIA prime sync"; 30 | offload.enable = lib.mkEnableOption "enable NVIDIA prime offload"; 31 | }; 32 | }; 33 | }; 34 | 35 | config = lib.mkIf cfg.enable { 36 | home.packages = with pkgs; [ 37 | xclip 38 | xdotool 39 | xorg.xdpyinfo 40 | xorg.xhost 41 | xorg.xkill 42 | xorg.xrandr 43 | xorg.xset 44 | ]; 45 | 46 | # Compatibility with xinit/sx 47 | home.file.".xinitrc" = { 48 | inherit (config.home.file.".xsession") executable text; 49 | }; 50 | xdg.configFile."sx/sxrc" = { 51 | inherit (config.home.file.".xsession") executable text; 52 | }; 53 | 54 | xresources.properties = { 55 | "Xft.dpi" = toString config.theme.fonts.dpi; 56 | }; 57 | 58 | xsession = { 59 | enable = true; 60 | initExtra = 61 | let 62 | xrandr = lib.getExe pkgs.xorg.xrandr; 63 | in 64 | lib.concatStringsSep "\n" [ 65 | # NVIDIA sync 66 | (lib.optionalString cfg.nvidia.prime.sync.enable '' 67 | ${xrandr} --setprovideroutputsource modesetting NVIDIA-0 68 | ${xrandr} --auto 69 | '') 70 | # Reverse PRIME 71 | (lib.optionalString cfg.nvidia.prime.offload.enable '' 72 | ${xrandr} --setprovideroutputsource NVIDIA-G0 modesetting 73 | '') 74 | ]; 75 | }; 76 | }; 77 | } 78 | -------------------------------------------------------------------------------- /modules/nixos/window-manager/xserver.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | ... 5 | }: 6 | 7 | { 8 | options.nixos.window-manager.xserver.enable = lib.mkEnableOption "xserver config" // { 9 | default = config.nixos.window-manager.enable; 10 | }; 11 | 12 | config = lib.mkIf config.nixos.window-manager.xserver.enable { 13 | nixos.home.extraModules = { 14 | home.keyboard = { 15 | inherit (config.services.xserver.xkb) layout variant; 16 | options = lib.splitString "," config.services.xserver.xkb.options; 17 | }; 18 | }; 19 | 20 | # Configure the virtual console keymap from the xserver keyboard settings 21 | console.useXkbConfig = true; 22 | 23 | # Configure special programs (i.e. hardware access) 24 | programs = { 25 | dconf.enable = true; 26 | light.enable = true; 27 | }; 28 | 29 | services = { 30 | # Enable autorandr service, i.e.: sleep.target 31 | autorandr.enable = true; 32 | 33 | # Enable libinput 34 | libinput = { 35 | enable = true; 36 | touchpad = { 37 | naturalScrolling = true; 38 | tapping = true; 39 | }; 40 | mouse = { 41 | accelProfile = "flat"; 42 | }; 43 | }; 44 | 45 | xserver = { 46 | enable = true; 47 | 48 | # Enable sx, a lightweight startx alternative 49 | displayManager.sx = { 50 | enable = true; 51 | addAsSession = true; 52 | }; 53 | 54 | xkb = { 55 | # X11 keyboard layout 56 | layout = lib.mkDefault "us"; 57 | variant = lib.mkDefault "intl"; 58 | # Remap Caps Lock to Esc, and use Super+Space to change layouts 59 | options = lib.mkDefault ( 60 | lib.concatStringsSep "," [ 61 | "caps:escape" 62 | "grp:win_space_toggle" 63 | ] 64 | ); 65 | }; 66 | }; 67 | }; 68 | 69 | # Try at least 3 times before considering the service failed 70 | # Default is 1 71 | systemd.services.autorandr.startLimitBurst = lib.mkForce 3; 72 | }; 73 | } 74 | -------------------------------------------------------------------------------- /modules/home-manager/window-manager/wayland/swayidle.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | lib, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.home-manager.window-manager.wayland.swayidle; 10 | swaylock = "${lib.getExe config.programs.swaylock.package} -f"; 11 | swaymsg = lib.getExe' config.wayland.windowManager.sway.package "swaymsg"; 12 | notify = toString ( 13 | pkgs.writeShellScript "notify" '' 14 | ${lib.getExe pkgs.libnotify} -t 30000 "30 seconds to lock" 15 | '' 16 | ); 17 | display = 18 | switch: 19 | toString ( 20 | pkgs.writeShellScript "display-${switch}" 21 | # bash 22 | '' 23 | case "''${XDG_CURRENT_DESKTOP,,}" in 24 | sway) 25 | ${swaymsg} "output * power ${switch}" 26 | ;; 27 | *) 28 | >&2 echo "Unknown desktop environment: $XDG_CURRENT_DESKTOP" 29 | ;; 30 | esac 31 | '' 32 | ); 33 | in 34 | { 35 | options.home-manager.window-manager.wayland.swayidle.enable = 36 | lib.mkEnableOption "swayidle config" 37 | // { 38 | default = config.home-manager.window-manager.wayland.enable; 39 | }; 40 | 41 | config = lib.mkIf cfg.enable { 42 | home.packages = with pkgs; [ swayidle ]; 43 | 44 | services.swayidle = { 45 | enable = true; 46 | events = { 47 | after-resume = display "on"; 48 | before-sleep = swaylock; 49 | lock = swaylock; 50 | }; 51 | timeouts = [ 52 | { 53 | timeout = 570; 54 | command = notify; 55 | } 56 | { 57 | timeout = 600; 58 | command = swaylock; 59 | } 60 | { 61 | timeout = 605; 62 | command = display "off"; 63 | resumeCommand = display "on"; 64 | } 65 | ]; 66 | }; 67 | 68 | systemd.user.services.swayidle = { 69 | Service = { 70 | inherit (config.home-manager.window-manager.systemd.service) 71 | RestartSec 72 | RestartSteps 73 | RestartMaxDelaySec 74 | ; 75 | }; 76 | }; 77 | }; 78 | } 79 | -------------------------------------------------------------------------------- /modules/home-manager/cli/irssi.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | let 4 | cfg = config.home-manager.cli.irssi; 5 | in 6 | { 7 | options.home-manager.cli.irssi = { 8 | enable = lib.mkEnableOption "irssi config" // { 9 | default = config.home-manager.cli.enable; 10 | }; 11 | dcc = { 12 | downloadPath = lib.mkOption { 13 | type = lib.types.path; 14 | default = "${config.device.media.directory}/Other"; 15 | description = "DCC's download path."; 16 | }; 17 | }; 18 | user = { 19 | nickName = lib.mkOption { 20 | type = lib.types.str; 21 | default = "k0kada_t"; 22 | description = "IRC's nickname."; 23 | }; 24 | realName = lib.mkOption { 25 | type = lib.types.str; 26 | default = cfg.user.nickName; 27 | description = "IRC's real name."; 28 | }; 29 | userName = lib.mkOption { 30 | type = lib.types.str; 31 | default = cfg.user.nickName; 32 | description = "IRC's username."; 33 | }; 34 | }; 35 | }; 36 | 37 | config = lib.mkIf cfg.enable { 38 | programs.irssi = { 39 | enable = true; 40 | networks = { 41 | rizon = { 42 | nick = cfg.user.nickName; 43 | server = { 44 | address = "irc.rizon.net"; 45 | port = 6697; 46 | autoConnect = true; 47 | }; 48 | channels = { 49 | nibl.autoJoin = true; 50 | HorribleSubs.autoJoin = true; 51 | }; 52 | }; 53 | }; 54 | extraConfig = '' 55 | settings = { 56 | core = { 57 | real_name = "${cfg.user.realName}"; 58 | user_name = "${cfg.user.userName}"; 59 | nick = "${cfg.user.nickName}"; 60 | }; 61 | "irc/dcc" = { 62 | dcc_autoget = "yes"; 63 | dcc_autoresume = "yes"; 64 | dcc_download_path = "${cfg.dcc.downloadPath}"; 65 | dcc_file_create_mode = "664"; 66 | dcc_mirc_ctcp = "yes"; 67 | dcc_port = "50000 50010"; 68 | }; 69 | }; 70 | ''; 71 | }; 72 | }; 73 | } 74 | -------------------------------------------------------------------------------- /modules/home-manager/editor/idea.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | flake, 6 | ... 7 | }: 8 | 9 | let 10 | cfg = config.home-manager.editor.idea; 11 | in 12 | { 13 | options.home-manager.editor.idea = { 14 | enable = lib.mkEnableOption "IntelliJ config"; 15 | packages = lib.mkOption { 16 | description = "Packages to add from IntelliJ."; 17 | default = with pkgs.jetbrains; [ idea-community ]; 18 | type = with lib.types; nullOr (listOf package); 19 | }; 20 | }; 21 | 22 | config = lib.mkIf cfg.enable { 23 | home = { 24 | file = { 25 | ".intellimacs".source = flake.inputs.intellimacs; 26 | ".ideavimrc".source = 27 | pkgs.writeText "ideavimrc" # vim 28 | '' 29 | " Enable Intellimacs 30 | source ~/.intellimacs/spacemacs.vim 31 | 32 | " Enable other Intellimacs modules 33 | source ~/.intellimacs/extra.vim 34 | source ~/.intellimacs/major.vim 35 | source ~/.intellimacs/hybrid.vim 36 | source ~/.intellimacs/which-key.vim 37 | 38 | " Comma for major mode 39 | nmap , m 40 | vmap , m 41 | 42 | " Plugins 43 | set commentary 44 | set easymotion 45 | set highlightedyank 46 | set ideajoin 47 | set mini-ai 48 | set NERDTree 49 | set surround 50 | set sneak 51 | 52 | " vim-highlightedyank 53 | let g:highlightedyank_highlight_duration = "300" 54 | 55 | " Vinegar-like 56 | nnoremap - :NERDTreeToggle 57 | 58 | " Unsets the 'last search pattern' 59 | nnoremap :noh 60 | 61 | " HACK: Workaround IDEA "eating" the character under cursor 62 | " For some reason it is only happening in " 63 | nnoremap vi" :normal! vi" 64 | nnoremap va" :normal! va" 65 | ''; 66 | }; 67 | 68 | packages = lib.mkIf (cfg.packages != null) cfg.packages; 69 | }; 70 | }; 71 | } 72 | -------------------------------------------------------------------------------- /modules/home-manager/window-manager/dunst.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | { 9 | options.home-manager.window-manager.dunst.enable = lib.mkEnableOption "dunst config" // { 10 | default = config.home-manager.window-manager.enable; 11 | }; 12 | 13 | config = lib.mkIf config.home-manager.window-manager.dunst.enable { 14 | home.packages = with pkgs; [ dunst ]; 15 | 16 | services.dunst = { 17 | enable = true; 18 | iconTheme = with config.gtk.iconTheme; { 19 | inherit name package; 20 | }; 21 | settings = 22 | with config.theme.colors; 23 | let 24 | theme = { 25 | background = base00; 26 | foreground = base05; 27 | }; 28 | in 29 | { 30 | global = { 31 | font = "${config.theme.fonts.gui.name} 8"; 32 | markup = true; 33 | format = "%s\\n%b"; 34 | sort = true; 35 | indicate_hidden = true; 36 | alignment = "left"; 37 | show_age_threshold = 60; 38 | word_wrap = true; 39 | ignore_newline = false; 40 | width = "(0,250)"; 41 | height = "(0,200)"; 42 | origin = "top-right"; 43 | notification_limit = 5; 44 | transparency = 0; 45 | idle_threshold = 120; 46 | follow = "mouse"; 47 | sticky_history = true; 48 | line_height = 0; 49 | padding = 8; 50 | horizontal_padding = 8; 51 | separator_color = base03; 52 | frame_width = 1; 53 | frame_color = base01; 54 | show_indicators = false; 55 | icon_position = "left"; 56 | min_icon_size = 48; 57 | max_icon_size = 48; 58 | }; 59 | urgency_low = { 60 | timeout = 5; 61 | } 62 | // theme; 63 | urgency_normal = { 64 | timeout = 10; 65 | } 66 | // theme; 67 | urgency_high = { 68 | timeout = 20; 69 | } 70 | // theme; 71 | }; 72 | }; 73 | }; 74 | } 75 | -------------------------------------------------------------------------------- /hosts/nixos/sankyuu-nixos/default.nix: -------------------------------------------------------------------------------- 1 | # Edit this configuration file to define what should be installed on 2 | # your system. Help is available in the configuration.nix(5) man page 3 | # and in the NixOS manual (accessible by running ‘nixos-help’). 4 | 5 | { 6 | pkgs, 7 | flake, 8 | ... 9 | }: 10 | 11 | { 12 | imports = [ 13 | ./disk-config.nix 14 | ./hardware-configuration.nix 15 | flake.inputs.disko.nixosModules.disko 16 | flake.inputs.hardware.nixosModules.lenovo-thinkpad-t14-amd-gen1 17 | ]; 18 | 19 | device = { 20 | type = "laptop"; 21 | net.ifaces = [ 22 | "enp2s0f0" 23 | "enp5s0" 24 | "wlan0" 25 | ]; 26 | }; 27 | 28 | boot.kernelPackages = pkgs.linuxPackages_lqx; 29 | 30 | # Use the systemd-boot EFI boot loader 31 | boot.loader.systemd-boot.enable = true; 32 | boot.loader.efi.canTouchEfiVariables = true; 33 | 34 | theme = { 35 | fonts.dpi = 150; 36 | wallpaper.path = pkgs.wallpapers.hatsune-miku_stylized-ultrawide; 37 | }; 38 | 39 | nixos = { 40 | server = { 41 | ssh.enable = true; 42 | tailscale.enable = true; 43 | }; 44 | system = { 45 | binfmt.enable = true; 46 | }; 47 | }; 48 | 49 | services = { 50 | # Used for firmware updates 51 | fwupd.enable = true; 52 | tlp.settings = { 53 | # Set battery thresholds 54 | START_CHARGE_THRESH_BAT0 = 75; 55 | STOP_CHARGE_THRESH_BAT0 = 80; 56 | }; 57 | }; 58 | 59 | # https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1849 60 | systemd.services.fix-mic-light = { 61 | description = "Disables mic light (turned on by default)"; 62 | script = '' 63 | echo 0 > /sys/class/leds/platform\:\:micmute/brightness 64 | ''; 65 | serviceConfig.Type = "oneshot"; 66 | wantedBy = [ "multi-user.target" ]; # starts after login 67 | }; 68 | 69 | time.timeZone = "Europe/Dublin"; 70 | 71 | # This value determines the NixOS release with which your system is to be 72 | # compatible, in order to avoid breaking some software such as database 73 | # servers. You should change this only after NixOS release notes say you 74 | # should. 75 | system.stateVersion = "24.05"; # Did you read the comment? 76 | } 77 | -------------------------------------------------------------------------------- /modules/home-manager/cli/tmux.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | lib, 5 | ... 6 | }: 7 | 8 | { 9 | options.home-manager.cli.tmux.enable = lib.mkEnableOption "Tmux config" // { 10 | default = config.home-manager.cli.enable; 11 | }; 12 | 13 | config = lib.mkIf config.home-manager.cli.tmux.enable { 14 | programs = { 15 | fzf.tmux.enableShellIntegration = true; 16 | tmux = { 17 | enable = true; 18 | aggressiveResize = true; 19 | baseIndex = 1; 20 | clock24 = true; 21 | escapeTime = 0; 22 | historyLimit = 10000; 23 | keyMode = "vi"; 24 | mouse = true; 25 | newSession = true; 26 | sensibleOnTop = true; 27 | secureSocket = false; 28 | terminal = "screen-256color"; 29 | extraConfig = '' 30 | # true color 31 | set -as terminal-features ",xterm-256color:RGB" 32 | 33 | # enable auto renaming 34 | setw -g automatic-rename on 35 | 36 | # enable wm window titles 37 | set -g set-titles on 38 | 39 | # hostname, window number, program name 40 | set -g set-titles-string '#H: #S.#I.#P #W' 41 | 42 | # monitor activity between windows 43 | setw -g monitor-activity on 44 | set -g visual-activity on 45 | 46 | # show current mode 47 | set -g status-left '#{prefix_highlight} ' 48 | set -g status-right ' "#{=21:pane_title}" | %H:%M %d-%b-%y' 49 | ''; 50 | plugins = with pkgs; [ 51 | { 52 | plugin = tmuxPlugins.tmux-colors-solarized; 53 | extraConfig = '' 54 | set -g @colors-solarized '256' 55 | ''; 56 | } 57 | { 58 | plugin = tmuxPlugins.prefix-highlight; 59 | extraConfig = '' 60 | set -g @prefix_highlight_prefix_prompt 'Prefix' 61 | set -g @prefix_highlight_show_copy_mode 'on' 62 | set -g @prefix_highlight_copy_prompt 'Copy' 63 | set -g @prefix_highlight_empty_has_affixes 'on' 64 | set -g @prefix_highlight_empty_prompt 'Tmux' 65 | ''; 66 | } 67 | tmuxPlugins.copycat 68 | tmuxPlugins.pain-control 69 | tmuxPlugins.yank 70 | ]; 71 | }; 72 | }; 73 | }; 74 | } 75 | -------------------------------------------------------------------------------- /modules/nixos/nix/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | libEx, 5 | pkgs, 6 | flake, 7 | ... 8 | }: 9 | 10 | let 11 | cfg = config.nixos.nix; 12 | in 13 | { 14 | imports = [ 15 | ./diff.nix 16 | ./remote-builders.nix 17 | ]; 18 | 19 | options.nixos.nix = { 20 | enable = lib.mkEnableOption "nix/nixpkgs config" // { 21 | default = true; 22 | }; 23 | tmpOnDisk = lib.mkEnableOption "set nix's TMPDIR to /var/tmp (disk instead tmpfs)" // { 24 | # TODO: remove this once nix 2.31.0+ becomes the default 25 | # https://github.com/NixOS/nixpkgs/issues/54707#issuecomment-3397189236 26 | default = config.boot.tmp.useTmpfs && lib.versionAtLeast config.nix.package.version "2.31.0"; 27 | }; 28 | }; 29 | 30 | config = lib.mkIf cfg.enable { 31 | environment.systemPackages = with pkgs; [ nixos-cleanup ]; 32 | 33 | nix = { 34 | gc = { 35 | automatic = true; 36 | persistent = true; 37 | randomizedDelaySec = "15m"; 38 | dates = "3:15"; 39 | options = "--delete-older-than 7d"; 40 | }; 41 | # Optimise nix-store via service 42 | optimise.automatic = true; 43 | # Reduce disk usage 44 | daemonIOSchedClass = "best-effort"; 45 | daemonIOSchedPriority = 7; 46 | # Leave nix builds as a background task 47 | daemonCPUSchedPolicy = "batch"; 48 | 49 | # Customized nixpkgs, e.g.: `nix shell nixpkgs_#snes9x` 50 | registry.nixpkgs_.flake = flake; 51 | 52 | settings = lib.mkMerge [ 53 | # Needs to use substituters/trusted-public-keys otherwise it doesn't 54 | # work in nix-daemon 55 | (libEx.translateKeys { 56 | "extra-substituters" = "substituters"; 57 | "extra-trusted-public-keys" = "trusted-public-keys"; 58 | } flake.outputs.internal.configs.nix) 59 | { 60 | trusted-users = [ 61 | "root" 62 | "@wheel" 63 | ]; 64 | auto-optimise-store = true; 65 | } 66 | ]; 67 | }; 68 | 69 | nixpkgs = { 70 | config = flake.outputs.internal.configs.nixpkgs; 71 | overlays = [ flake.outputs.overlays.default ]; 72 | }; 73 | 74 | # Change build dir to /var/tmp 75 | systemd.services.nix-daemon = { 76 | environment.TMPDIR = lib.mkIf cfg.tmpOnDisk "/var/tmp"; 77 | }; 78 | }; 79 | } 80 | -------------------------------------------------------------------------------- /modules/home-manager/window-manager/x11/autorandr/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.home-manager.window-manager.x11.autorandr; 10 | in 11 | { 12 | options.home-manager.window-manager.x11.autorandr = { 13 | enable = lib.mkEnableOption "autorandr config" // { 14 | default = config.home-manager.window-manager.x11.enable; 15 | }; 16 | defaultProfile = lib.mkOption { 17 | description = "Default autorandr profile."; 18 | type = lib.types.str; 19 | default = "horizontal"; 20 | }; 21 | extraHooks = lib.mkOption { 22 | description = "Additional hooks."; 23 | type = lib.types.attrs; 24 | default = 25 | let 26 | inherit (config.home-manager) hostName; 27 | configFile = ./${hostName}.nix; 28 | in 29 | lib.optionalAttrs (builtins.pathExists configFile) (import configFile); 30 | }; 31 | }; 32 | 33 | config = lib.mkIf cfg.enable { 34 | home.activation = 35 | let 36 | inherit (config.xdg) configHome; 37 | in 38 | { 39 | autorandrCreateDefaultProfile = 40 | lib.hm.dag.entryAfter [ "writeBoundary" ] 41 | # bash 42 | '' 43 | run mkdir -p "${configHome}/autorandr" 44 | run cd "${configHome}/autorandr" 45 | run ln -sf $VERBOSE_ARG ${cfg.defaultProfile} default 46 | ''; 47 | }; 48 | 49 | programs.autorandr = { 50 | enable = true; 51 | hooks = lib.mkMerge [ 52 | { 53 | postswitch = { 54 | notify-i3 = "${lib.getExe' pkgs.i3 "i3-msg"} restart"; 55 | reset-wallpaper = "systemctl restart --user wallpaper.service"; 56 | }; 57 | } 58 | cfg.extraHooks 59 | ]; 60 | }; 61 | 62 | xsession.initExtra = lib.mkAfter '' 63 | ${lib.getExe pkgs.autorandr} --change --default default 64 | ''; 65 | 66 | # Configure autorandr globally 67 | xdg.configFile = { 68 | # Skip gamma settings since this is controlled by gammastep 69 | "autorandr/settings.ini" = { 70 | inherit (config.programs.autorandr) enable; 71 | text = lib.generators.toINI { } { 72 | config = { 73 | skip-options = "gamma"; 74 | }; 75 | }; 76 | }; 77 | }; 78 | }; 79 | } 80 | -------------------------------------------------------------------------------- /modules/home-manager/desktop/fonts/fontconfig.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.home-manager.desktop.fonts.fontconfig; 10 | cfgFc = config.fonts.fontconfig; 11 | in 12 | { 13 | options.home-manager.desktop.fonts.fontconfig = { 14 | enable = lib.mkEnableOption "Fontconfig config" // { 15 | default = config.home-manager.desktop.fonts.enable; 16 | }; 17 | }; 18 | 19 | config = lib.mkMerge [ 20 | (lib.mkIf cfg.enable { 21 | home.packages = with pkgs; [ 22 | noto-fonts 23 | noto-fonts-cjk-sans 24 | noto-fonts-cjk-serif 25 | noto-fonts-color-emoji 26 | ]; 27 | 28 | fonts.fontconfig = { 29 | # Enable fonts in home.packages to be available to applications 30 | enable = true; 31 | defaultFonts = { 32 | monospace = [ "Noto Sans Mono" ]; 33 | serif = [ "Noto Serif" ]; 34 | sansSerif = [ "Noto Sans" ]; 35 | emoji = [ "Noto Color Emoji" ]; 36 | }; 37 | }; 38 | }) 39 | 40 | (lib.mkIf (cfg.enable && config.home-manager.window-manager.enable) { 41 | # https://github.com/GNOME/gsettings-desktop-schemas/blob/8527b47348ce0573694e0e254785e7c0f2150e16/schemas/org.gnome.desktop.interface.gschema.xml.in#L276-L296 42 | dconf.settings = { 43 | "org/gnome/desktop/interface" = with cfgFc; { 44 | "color-scheme" = "prefer-dark"; 45 | "font-antialiasing" = 46 | if antialiasing then if (subpixelRendering == "none") then "grayscale" else "rgba" else "none"; 47 | "font-hinting" = builtins.replaceStrings [ "hint" ] [ "" ] hinting; 48 | "font-rgba-order" = subpixelRendering; 49 | }; 50 | }; 51 | 52 | services.xsettingsd = { 53 | enable = true; 54 | settings = { 55 | # Applications like Java/Wine doesn't use Fontconfig settings, 56 | # but uses it from here 57 | "Xft/Antialias" = cfgFc.antialiasing; 58 | "Xft/Hinting" = cfgFc.hinting != null; 59 | "Xft/HintStyle" = cfgFc.hinting; 60 | "Xft/RGBA" = cfgFc.subpixelRendering; 61 | }; 62 | }; 63 | 64 | systemd.user.services.xsettingsd = { 65 | Service = { 66 | inherit (config.home-manager.window-manager.systemd.service) 67 | RestartSec 68 | RestartSteps 69 | RestartMaxDelaySec 70 | ; 71 | Restart = lib.mkForce "on-failure"; 72 | }; 73 | }; 74 | }) 75 | ]; 76 | } 77 | -------------------------------------------------------------------------------- /treefmt.nix: -------------------------------------------------------------------------------- 1 | { pkgs, lib, ... }: 2 | { 3 | projectRootFile = "flake.nix"; 4 | 5 | programs = { 6 | deadnix.enable = true; 7 | jsonfmt.enable = true; 8 | nixfmt.enable = true; 9 | ruff-check.enable = true; 10 | ruff-format.enable = true; 11 | shellcheck.enable = true; 12 | shfmt.enable = true; 13 | statix = { 14 | enable = true; 15 | disabled-lints = [ 16 | "empty_pattern" 17 | "repeated_keys" 18 | ]; 19 | }; 20 | }; 21 | 22 | settings = { 23 | global.excludes = [ 24 | "LICENSE" 25 | "*.md" 26 | "*.plist" 27 | "*.toml" 28 | "*.zsh" 29 | "modules/home-manager/editor/emacs/doom-emacs/*" 30 | # auto-generated 31 | ".github/workflows/*.yml" 32 | ]; 33 | formatter = { 34 | github-actions = 35 | let 36 | mkGHActionsYAML = 37 | name: 38 | pkgs.runCommand "make-${name}-yaml" 39 | { 40 | buildInputs = with pkgs; [ 41 | actionlint 42 | yj 43 | ]; 44 | json = builtins.toJSON (import ./actions/${name}.nix); 45 | passAsFile = [ "json" ]; 46 | } 47 | '' 48 | mkdir -p $out 49 | yj -jy < "$jsonPath" > $out/${name}.yml 50 | actionlint -verbose $out/${name}.yml 51 | ''; 52 | generateGhActions = 53 | let 54 | ghActionsYAMLs = map mkGHActionsYAML [ 55 | "build-and-cache" 56 | "update-flakes" 57 | "update-flakes-after" 58 | "validate-flakes" 59 | ]; 60 | resultDir = ".github/workflows"; 61 | in 62 | pkgs.writeShellApplication { 63 | name = "generate-gh-actions"; 64 | text = '' 65 | rm -rf "${resultDir}" 66 | mkdir -p "${resultDir}" 67 | for dir in ${builtins.toString ghActionsYAMLs}; do 68 | cp -f $dir/*.yml "${resultDir}" 69 | done 70 | echo Done! 71 | ''; 72 | }; 73 | 74 | in 75 | { 76 | command = lib.getExe generateGhActions; 77 | includes = [ "actions/*.nix" ]; 78 | priority = 1; 79 | }; 80 | ruff-format.includes = [ 81 | "*.py" 82 | "*.pyi" 83 | # VapourSynth files 84 | "*.vpy" 85 | "*.vpyi" 86 | ]; 87 | }; 88 | }; 89 | } 90 | -------------------------------------------------------------------------------- /modules/home-manager/window-manager/wayland/swaylock.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | lib, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.home-manager.window-manager.wayland.swaylock; 10 | kbLayouts = lib.splitString "," config.home.keyboard.layout; 11 | in 12 | { 13 | options.home-manager.window-manager.wayland.swaylock.enable = 14 | lib.mkEnableOption "swaylock config" 15 | // { 16 | default = config.home-manager.window-manager.wayland.enable; 17 | }; 18 | 19 | config = lib.mkIf cfg.enable { 20 | programs.swaylock = { 21 | enable = true; 22 | settings = with config.theme.colors; { 23 | font = config.theme.fonts.gui.name; 24 | indicator-caps-lock = true; 25 | show-keyboard-layout = true; 26 | # https://stackoverflow.com/a/506662 27 | image = 28 | with pkgs; 29 | toString ( 30 | runCommand "wallpaper-pixelated" { buildInputs = [ imagemagick ]; } '' 31 | convert -scale 1% -scale 10000% ${config.theme.wallpaper.path} $out 32 | '' 33 | ); 34 | scaling = config.theme.wallpaper.scale; 35 | 36 | inside-color = base01; 37 | line-color = base01; 38 | ring-color = base05; 39 | text-color = base05; 40 | 41 | inside-clear-color = base0A; 42 | line-clear-color = base0A; 43 | ring-clear-color = base00; 44 | text-clear-color = base00; 45 | 46 | inside-caps-lock-color = base03; 47 | line-caps-lock-color = base03; 48 | ring-caps-lock-color = base00; 49 | text-caps-lock-color = base00; 50 | 51 | inside-ver-color = base0D; 52 | line-ver-color = base0D; 53 | ring-ver-color = base00; 54 | text-ver-color = base00; 55 | 56 | inside-wrong-color = base08; 57 | line-wrong-color = base08; 58 | ring-wrong-color = base00; 59 | text-wrong-color = base00; 60 | 61 | caps-lock-bs-hl-color = base08; 62 | caps-lock-key-hl-color = base0C; 63 | bs-hl-color = base08; 64 | key-hl-color = base0C; 65 | separator-color = "#00000000"; # transparent 66 | layout-bg-color = "#00000050"; # semi-transparent black 67 | 68 | # when we have 0 keyboard layouts, it probably means we are using HM 69 | # standalone, so we can't trust the keyboard module 70 | hide-keyboard-layout = lib.mkIf ((builtins.length kbLayouts) == 1) true; 71 | ignore-empty-password = true; 72 | 73 | indicator-radius = 80; 74 | indicator-thickness = 10; 75 | }; 76 | }; 77 | }; 78 | } 79 | -------------------------------------------------------------------------------- /.github/workflows/update-flakes.yml: -------------------------------------------------------------------------------- 1 | concurrency: 2 | cancel-in-progress: true 3 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} 4 | jobs: 5 | update-flakes-x86_64-linux: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@v5 9 | - uses: cachix/install-nix-action@v31 10 | with: 11 | extra_nix_config: |- 12 | accept-flake-config = true 13 | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} 14 | nix_path: nixpkgs=channel:nixos-unstable 15 | - uses: cachix/cachix-action@v16 16 | with: 17 | authToken: ${{ secrets.CACHIX_TOKEN }} 18 | extraPullNames: nix-community,chaotic-nyx 19 | name: thiagokokada-nix-configs 20 | - name: nix-info -m 21 | run: | 22 | nix run '.#nix-info' -- -m 23 | - uses: thiagokokada/free-disk-space@main 24 | with: 25 | opt: true 26 | tool-cache: true 27 | usrlocal: true 28 | usrmisc: true 29 | - name: Update flake.lock 30 | run: | 31 | git config user.name "${{ github.actor }}" 32 | git config user.email "${{ github.actor }}@users.noreply.github.com" 33 | nix flake update --commit-lock-file 34 | - name: 'Build Home-Manager configs for: home-linux, steamdeck' 35 | run: |- 36 | nix build --print-build-logs '.#homeConfigurations.home-linux.activationPackage' 37 | nix build --print-build-logs '.#homeConfigurations.steamdeck.activationPackage' 38 | - name: 'Build NixOS configs for: blackrockshooter-nixos, hachune-nixos, sankyuu-nixos, zachune-nixos' 39 | run: |- 40 | nix build --print-build-logs '.#nixosConfigurations.blackrockshooter-nixos.config.system.build.toplevel' 41 | nix build --print-build-logs '.#nixosConfigurations.hachune-nixos.config.system.build.toplevel' 42 | nix build --print-build-logs '.#nixosConfigurations.sankyuu-nixos.config.system.build.toplevel' 43 | nix build --print-build-logs '.#nixosConfigurations.zachune-nixos.config.system.build.toplevel' 44 | - name: Create Pull Request 45 | uses: peter-evans/create-pull-request@v7 46 | with: 47 | body: | 48 | ## Run report 49 | 50 | https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} 51 | branch: flake-updates 52 | delete-branch: true 53 | title: Update flake.lock 54 | name: update-flakes 55 | "on": 56 | schedule: 57 | - cron: 40 4 * * 0,2,4,6 58 | workflow_dispatch: null 59 | -------------------------------------------------------------------------------- /modules/nixos/server/samba.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | lib, 5 | ... 6 | }: 7 | 8 | let 9 | inherit (config.device.media) directory; 10 | inherit (config.nixos.home) username; 11 | cfg = config.nixos.server.samba; 12 | in 13 | { 14 | options.nixos.server.samba = { 15 | enable = lib.mkEnableOption "Samba config"; 16 | shares = lib.mkOption { 17 | type = with lib.types; attrsOf str; 18 | description = "Samba shares."; 19 | default = { 20 | inherit (config.users.users.${username}) home; 21 | media = directory; 22 | }; 23 | }; 24 | }; 25 | 26 | config = 27 | with config.users.users.${username}; 28 | lib.mkIf cfg.enable { 29 | environment.systemPackages = with pkgs; [ samba ]; 30 | 31 | services = { 32 | # Enable Samba 33 | samba = { 34 | enable = true; 35 | openFirewall = true; 36 | settings = 37 | with config.networking; 38 | { 39 | global = { 40 | "workgroup" = "WORKGROUP"; 41 | "local master" = true; 42 | "preferred master" = true; 43 | "server string" = hostName; 44 | "netbios name" = hostName; 45 | "use sendfile" = true; 46 | "hosts allow" = lib.concatStringsSep " " [ 47 | "192.168.0.0/16" 48 | "172.16.0.0/12" 49 | "10.0.0.0/8" 50 | (lib.optionalString config.nixos.server.tailscale.enable "100.64.0.0/10") 51 | "localhost" 52 | ]; 53 | "hosts deny" = "0.0.0.0/0"; 54 | "bind interfaces only" = lib.mkIf config.nixos.server.tailscale.enable false; 55 | "guest account" = "nobody"; 56 | "map to guest" = "bad user"; 57 | "mangled names" = false; 58 | "vfs objects" = "catia fruit"; 59 | }; 60 | } 61 | // (lib.mapAttrs (_: path: { 62 | inherit path; 63 | "browseable" = true; 64 | "read only" = false; 65 | "guest ok" = false; 66 | "create mask" = "0644"; 67 | "directory mask" = "0755"; 68 | # Needs to manually add the password for a new user using: 69 | # smbpasswd -a 70 | "force user" = username; 71 | "force group" = group; 72 | }) cfg.shares); 73 | }; 74 | 75 | # advertise to Windows hosts 76 | samba-wsdd = { 77 | enable = true; 78 | openFirewall = true; 79 | }; 80 | }; 81 | }; 82 | } 83 | -------------------------------------------------------------------------------- /.github/workflows/update-flakes-after.yml: -------------------------------------------------------------------------------- 1 | concurrency: 2 | cancel-in-progress: true 3 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} 4 | jobs: 5 | update-flakes-aarch64-darwin: 6 | if: ${{ github.event.workflow_run.conclusion == 'success' }} 7 | runs-on: macos-latest 8 | steps: 9 | - uses: actions/checkout@v5 10 | - uses: cachix/install-nix-action@v31 11 | with: 12 | extra_nix_config: |- 13 | accept-flake-config = true 14 | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} 15 | nix_path: nixpkgs=channel:nixos-unstable 16 | - uses: cachix/cachix-action@v16 17 | with: 18 | authToken: ${{ secrets.CACHIX_TOKEN }} 19 | extraPullNames: nix-community,chaotic-nyx 20 | name: thiagokokada-nix-configs 21 | - name: nix-info -m 22 | run: | 23 | nix run '.#nix-info' -- -m 24 | - name: 'Build Home-Manager configs for: home-macos' 25 | run: nix build --print-build-logs '.#homeConfigurations.home-macos.activationPackage' 26 | - name: 'Build nix-darwin configs for: Sekai-MacBook-Pro' 27 | run: nix build --print-build-logs '.#darwinConfigurations.Sekai-MacBook-Pro.system' 28 | update-flakes-aarch64-linux: 29 | if: ${{ github.event.workflow_run.conclusion == 'success' }} 30 | runs-on: ubuntu-24.04-arm 31 | steps: 32 | - uses: actions/checkout@v5 33 | - uses: cachix/install-nix-action@v31 34 | with: 35 | extra_nix_config: |- 36 | accept-flake-config = true 37 | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} 38 | nix_path: nixpkgs=channel:nixos-unstable 39 | - uses: cachix/cachix-action@v16 40 | with: 41 | authToken: ${{ secrets.CACHIX_TOKEN }} 42 | extraPullNames: nix-community,chaotic-nyx 43 | name: thiagokokada-nix-configs 44 | - name: nix-info -m 45 | run: | 46 | nix run '.#nix-info' -- -m 47 | - uses: thiagokokada/free-disk-space@main 48 | with: 49 | opt: true 50 | tool-cache: true 51 | usrlocal: true 52 | usrmisc: true 53 | - name: 'Build Home-Manager configs for: penguin' 54 | run: nix build --print-build-logs '.#homeConfigurations.penguin.activationPackage' 55 | - name: 'Build NixOS configs for: zatsune-nixos' 56 | run: nix build --print-build-logs '.#nixosConfigurations.zatsune-nixos.config.system.build.toplevel' 57 | name: update-flakes-after 58 | "on": 59 | workflow_dispatch: null 60 | workflow_run: 61 | types: 62 | - completed 63 | workflows: 64 | - update-flakes 65 | -------------------------------------------------------------------------------- /modules/nixos/desktop/audio.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | 3 | let 4 | cfg = config.nixos.desktop.audio; 5 | in 6 | { 7 | options.nixos.desktop.audio = { 8 | enable = lib.mkEnableOption "audio config" // { 9 | default = config.nixos.desktop.enable; 10 | }; 11 | lowLatency = { 12 | enable = lib.mkEnableOption "low latency config"; 13 | quantum = lib.mkOption { 14 | description = "Quantum."; 15 | type = lib.types.int; 16 | default = 128; 17 | example = 32; # lowest latency possible 18 | }; 19 | rate = lib.mkOption { 20 | description = "Audio rate."; 21 | type = lib.types.int; 22 | default = 48000; 23 | }; 24 | }; 25 | }; 26 | 27 | config = lib.mkIf cfg.enable { 28 | # This allows PipeWire to run with realtime privileges (i.e: less cracks) 29 | security.rtkit.enable = true; 30 | 31 | services = { 32 | pipewire = { 33 | alsa.support32Bit = config.nixos.games.enable; 34 | extraConfig = lib.mkIf cfg.lowLatency.enable { 35 | pipewire."92-low-latency" = { 36 | context.properties = { 37 | default.clock.rate = cfg.lowLatency.rate; 38 | default.clock.quantum = cfg.lowLatency.quantum; 39 | default.clock.min-quantum = cfg.lowLatency.quantum; 40 | default.clock.max-quantum = cfg.lowLatency.quantum; 41 | }; 42 | }; 43 | pipewire-pulse."92-low-latency" = 44 | let 45 | req = "${toString cfg.lowLatency.quantum}/${toString cfg.lowLatency.rate}"; 46 | in 47 | { 48 | context.modules = [ 49 | { 50 | name = "libpipewire-module-protocol-pulse"; 51 | args = { 52 | pulse.min.req = req; 53 | pulse.default.req = req; 54 | pulse.max.req = req; 55 | pulse.min.quantum = req; 56 | pulse.max.quantum = req; 57 | }; 58 | } 59 | ]; 60 | stream.properties = { 61 | node.latency = req; 62 | resample.quality = 1; 63 | }; 64 | }; 65 | }; 66 | wireplumber = { 67 | enable = true; 68 | extraConfig."10-bluez" = { 69 | "monitor.bluez.properties" = { 70 | "bluez5.enable-sbc-xq" = true; 71 | "bluez5.enable-msbc" = true; 72 | "bluez5.enable-hw-volume" = true; 73 | "bluez5.roles" = [ 74 | "hsp_hs" 75 | "hsp_ag" 76 | "hfp_hf" 77 | "hfp_ag" 78 | ]; 79 | }; 80 | }; 81 | }; 82 | }; 83 | }; 84 | }; 85 | } 86 | -------------------------------------------------------------------------------- /modules/home-manager/desktop/mpv/motion-based-interpolation.vpy: -------------------------------------------------------------------------------- 1 | # vim: set ft=python: 2 | 3 | # see the README at https://gist.github.com/phiresky/4bfcfbbd05b3c2ed8645 4 | # source: https://github.com/mpv-player/mpv/issues/2149 5 | # source: https://github.com/mpv-player/mpv/issues/566 6 | # source: https://github.com/haasn/gentoo-conf/blob/nanodesu/home/nand/.mpv/filters/mvtools.vpy 7 | 8 | from vapoursynth import core 9 | 10 | core.std.LoadPlugin(path="libmvtools.so") 11 | # ref: http://avisynth.org.ru/mvtools/mvtools2.html#functions 12 | # default is 400, less means interpolation will only happen when it will work well 13 | ignore_threshold = 140 14 | # if n% of blocks change more than threshold then don't interpolate at all (default is 51%) 15 | scene_change_percentage = 15 16 | 17 | dst_fps = display_fps 18 | # Interpolating to fps higher than 60 is too CPU-expensive, smoothmotion can handle the rest. 19 | # while (dst_fps > 60): 20 | # dst_fps /= 2 21 | 22 | if "video_in" in globals(): 23 | # realtime 24 | clip = video_in 25 | # Needed because clip FPS is missing 26 | src_fps_num = int(container_fps * 1e8) 27 | src_fps_den = int(1e8) 28 | clip = core.std.AssumeFPS(clip, fpsnum=src_fps_num, fpsden=src_fps_den) 29 | else: 30 | # run with vspipe 31 | clip = core.ffms2.Source(source=in_filename) 32 | dst_fps = float(dst_fps) 33 | 34 | # resolution in megapixels. 1080p ≈ 2MP, 720p ≈ 1MP 35 | mpix = clip.width * clip.height / 1000000 36 | 37 | # Skip interpolation for >1080p or 60 Hz content due to performance 38 | if not (mpix > 2.5 or clip.fps_num / clip.fps_den > 59): 39 | analParams = { 40 | "overlap": 0, 41 | "search": 3, 42 | "truemotion": True, 43 | #'chrome': True, 44 | #'blksize':16, 45 | #'searchparam':1 46 | } 47 | blockParams = { 48 | "thscd1": ignore_threshold, 49 | "thscd2": int(scene_change_percentage * 255 / 100), 50 | "mode": 3, 51 | } 52 | 53 | if mpix > 1.5: 54 | # can't handle these on Full HD with Intel i5-2500k 55 | # see the description of these parameters in http://avisynth.org.ru/mvtools/mvtools2.html#functions 56 | analParams["search"] = 0 57 | blockParams["mode"] = 0 58 | quality = "low" 59 | else: 60 | quality = "high" 61 | 62 | dst_fps_num = int(dst_fps * 1e4) 63 | dst_fps_den = int(1e4) 64 | print( 65 | "Reflowing from {} fps to {} fps (quality={})".format( 66 | clip.fps_num / clip.fps_den, dst_fps_num / dst_fps_den, quality 67 | ) 68 | ) 69 | 70 | sup = core.mv.Super(clip, pel=2) 71 | bvec = core.mv.Analyse(sup, isb=True, **analParams) 72 | fvec = core.mv.Analyse(sup, isb=False, **analParams) 73 | clip = core.mv.BlockFPS( 74 | clip, sup, bvec, fvec, num=dst_fps_num, den=dst_fps_den, **blockParams 75 | ) 76 | 77 | clip.set_output() 78 | -------------------------------------------------------------------------------- /modules/home-manager/window-manager/x11/rofi.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | { 9 | options.home-manager.window-manager.x11.rofi.enable = lib.mkEnableOption "rofi config" // { 10 | default = config.home-manager.window-manager.x11.enable; 11 | }; 12 | 13 | config = lib.mkIf config.home-manager.window-manager.x11.rofi.enable { 14 | programs.rofi = { 15 | inherit (config.home-manager.window-manager.default) terminal; 16 | enable = true; 17 | package = 18 | with pkgs; 19 | rofi.override { 20 | plugins = [ 21 | rofi-calc 22 | rofi-emoji 23 | ]; 24 | }; 25 | font = with config.theme.fonts; "${gui.package} 14"; 26 | theme = 27 | let 28 | l = config.lib.formats.rasi.mkLiteral; 29 | in 30 | with config.theme.colors; 31 | { 32 | "*" = { 33 | background-color = l base00; 34 | border-color = l base01; 35 | text-color = l base05; 36 | spacing = 0; 37 | width = l "512px"; 38 | }; 39 | 40 | inputbar = { 41 | border = l "0 0 1px 0"; 42 | children = map l [ 43 | "prompt" 44 | "entry" 45 | ]; 46 | }; 47 | 48 | prompt = { 49 | padding = l "16px"; 50 | border = l "0 1px 0 0"; 51 | }; 52 | 53 | textbox = { 54 | background-color = l base01; 55 | border = l "0 0 1px 0"; 56 | border-color = l base00; 57 | padding = l "8px 16px"; 58 | }; 59 | 60 | entry = { 61 | padding = l "16px"; 62 | }; 63 | 64 | listview = { 65 | cycle = true; 66 | margin = l "0 0 -1px 0"; 67 | scrollbar = false; 68 | }; 69 | 70 | element = { 71 | border = l "2px"; 72 | border-color = l base00; 73 | padding = l "8px"; 74 | }; 75 | 76 | element-icon = { 77 | size = l "28px"; 78 | border = l "0 4px"; 79 | border-color = l base00; 80 | }; 81 | 82 | "element selected" = { 83 | border-color = l base0D; 84 | color = l base00; 85 | }; 86 | }; 87 | 88 | extraConfig = { 89 | show-icons = true; 90 | modi = "drun,emoji,ssh"; 91 | kb-row-up = "Up,Control+k"; 92 | kb-row-down = "Down,Control+j"; 93 | kb-accept-entry = "Control+m,Return,KP_Enter"; 94 | kb-remove-to-eol = "Control+Shift+e"; 95 | kb-mode-next = "Shift+Right,Control+Tab"; 96 | kb-mode-previous = "Shift+Left,Control+Shift+Tab"; 97 | kb-remove-char-back = "BackSpace"; 98 | }; 99 | }; 100 | }; 101 | } 102 | -------------------------------------------------------------------------------- /modules/nixos/dev/virtualisation/libvirt.nix: -------------------------------------------------------------------------------- 1 | { 2 | pkgs, 3 | lib, 4 | config, 5 | ... 6 | }: 7 | 8 | let 9 | inherit (config.nixos.home) username; 10 | cfg = config.nixos.dev.virtualisation.libvirt; 11 | in 12 | { 13 | options.nixos.dev.virtualisation.libvirt = { 14 | enable = lib.mkEnableOption "libvirt config" // { 15 | default = config.nixos.dev.virtualisation.enable; 16 | }; 17 | vfioPci = { 18 | enable = lib.mkEnableOption "vfio-pci (PCI passthrough)"; 19 | ids = lib.mkOption { 20 | type = with lib.types; listOf str; 21 | description = "PCI-e devices that will be passthrough to the VM."; 22 | # run iommu-script to get the devices and groups 23 | example = [ 24 | "1002:67b0" 25 | "1002:aac8" 26 | ]; 27 | default = [ ]; 28 | }; 29 | }; 30 | }; 31 | 32 | config = lib.mkMerge [ 33 | { 34 | environment.systemPackages = with pkgs; [ 35 | # https://wiki.nixos.org/wiki/Libvirt#Default_networking 36 | dnsmasq 37 | gnome-boxes 38 | ]; 39 | 40 | # Not completely sure if this is needed but should fix some NAT issues 41 | networking.firewall.checkReversePath = "loose"; 42 | 43 | virtualisation = { 44 | libvirtd = { 45 | enable = true; 46 | qemu = { 47 | package = pkgs.qemu_kvm; 48 | runAsRoot = true; 49 | swtpm.enable = true; 50 | }; 51 | }; 52 | 53 | spiceUSBRedirection.enable = true; 54 | }; 55 | 56 | users.users.${username}.extraGroups = [ "libvirtd" ]; 57 | } 58 | (lib.mkIf cfg.vfioPci.enable { 59 | boot = { 60 | initrd.kernelModules = [ 61 | "vfio_pci" 62 | "vfio" 63 | "vfio_iommu_type1" 64 | "vfio_virqfd" 65 | ]; 66 | kernelParams = [ 67 | "rd.driver.pre=vfio-pci" 68 | ] 69 | ++ lib.optionals (cfg.vfioPci != [ ]) [ 70 | "vfio-pci.ids=${lib.concatStringsSep "," cfg.vfioPci.ids}" 71 | ]; 72 | }; 73 | 74 | programs.virt-manager.enable = true; 75 | 76 | environment.systemPackages = 77 | let 78 | iommu-script = pkgs.writeShellScriptBin "iommu" '' 79 | for d in /sys/kernel/iommu_groups/*/devices/*; do 80 | n=''${d#*/iommu_groups/*}; n=''${n%%/*} 81 | printf 'IOMMU Group %s ' "$n" 82 | lspci -nns "''${d##*/}" 83 | done 84 | ''; 85 | in 86 | [ 87 | iommu-script 88 | ]; 89 | 90 | # Very likely we want the desktop session if we are using libvirt 91 | nixos.games.jovian.bootInDesktopMode = true; 92 | 93 | # Disable early KMS 94 | # TODO: make this works for other GPU makers 95 | jovian.hardware.amd.gpu.enableEarlyModesetting = false; 96 | hardware.amdgpu.initrd.enable = false; 97 | }) 98 | ]; 99 | } 100 | -------------------------------------------------------------------------------- /hosts/nixos/blackrockshooter-nixos/default.nix: -------------------------------------------------------------------------------- 1 | # Edit this configuration file to define what should be installed on 2 | # your system. Help is available in the configuration.nix(5) man page 3 | # and in the NixOS manual (accessible by running ‘nixos-help’). 4 | 5 | { 6 | pkgs, 7 | lib, 8 | flake, 9 | ... 10 | }: 11 | 12 | { 13 | imports = [ 14 | ./disk-config.nix 15 | ./hardware-configuration.nix 16 | flake.inputs.disko.nixosModules.disko 17 | flake.inputs.hardware.nixosModules.common-cpu-amd 18 | flake.inputs.hardware.nixosModules.common-gpu-amd 19 | ]; 20 | 21 | device = { 22 | type = "steam-machine"; 23 | net.ifaces = [ 24 | "enp8s0" 25 | "wlp7s0" 26 | ]; 27 | }; 28 | 29 | boot = { 30 | kernelPackages = pkgs.linuxPackages_lqx; 31 | # Use the systemd-boot EFI boot loader 32 | loader = { 33 | efi.canTouchEfiVariables = true; 34 | systemd-boot = { 35 | enable = true; 36 | consoleMode = "max"; 37 | }; 38 | }; 39 | }; 40 | 41 | fonts.fontconfig.subpixel.rgba = "rgb"; 42 | 43 | nixos = { 44 | games.enable = true; 45 | home.restoreBackups = true; 46 | server = { 47 | plex.enable = true; 48 | rtorrent = { 49 | enable = true; 50 | ratio.enable = true; 51 | }; 52 | ssh.enable = true; 53 | }; 54 | system = { 55 | gpu.maker = "amd"; 56 | binfmt = { 57 | enable = true; 58 | windows.enable = true; 59 | }; 60 | }; 61 | }; 62 | 63 | time.timeZone = "Europe/Dublin"; 64 | 65 | services = { 66 | # Used for firmware updates 67 | fwupd.enable = true; 68 | ollama.loadModels = [ 69 | "deepseek-r1:14b" 70 | ]; 71 | }; 72 | 73 | specialisation.sway.configuration = { 74 | boot.loader.systemd-boot.sortKey = "s_nixos"; 75 | device.type = lib.mkForce "desktop"; 76 | system.nixos.tags = [ "with-sway" ]; 77 | }; 78 | 79 | networking.networkmanager = { 80 | connectionConfig = { 81 | # Disable powersave for Wi-Fi to see if this improves reliability 82 | "wifi.powersave" = 2; 83 | }; 84 | # iwd doesn't allow for pinning a specific BSSID (i.e., router by MAC), 85 | # but since mt7925e is kinda buggy right now we need this support to 86 | # pin 2.4GHz, so go back to wpa_supplicant 87 | wifi.backend = "wpa_supplicant"; 88 | }; 89 | 90 | systemd.services.after-sleep-nm = { 91 | description = "Restart NetworkManager after sleep"; 92 | wantedBy = [ "suspend.target" ]; 93 | after = [ "suspend.target" ]; 94 | script = # bash 95 | '' 96 | sleep 2 97 | systemctl restart NetworkManager.service 98 | ''; 99 | serviceConfig = { 100 | Type = "oneshot"; 101 | }; 102 | }; 103 | 104 | # This value determines the NixOS release with which your system is to be 105 | # compatible, in order to avoid breaking some software such as database 106 | # servers. You should change this only after NixOS release notes say you 107 | # should. 108 | system.stateVersion = "25.05"; # Did you read the comment? 109 | } 110 | -------------------------------------------------------------------------------- /modules/nixos/system/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | flake, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.nixos.system; 10 | in 11 | { 12 | imports = [ 13 | ./binfmt.nix 14 | ./cli.nix 15 | ./gpu.nix 16 | ./networkd.nix 17 | ./smart.nix 18 | ./vm.nix 19 | ]; 20 | 21 | options.nixos.system = { 22 | enable = lib.mkEnableOption "system config" // { 23 | default = true; 24 | }; 25 | motd.enable = lib.mkEnableOption "show message of the day" // { 26 | default = true; 27 | }; 28 | zram.enable = lib.mkEnableOption "page compression" // { 29 | default = true; 30 | }; 31 | }; 32 | 33 | config = lib.mkIf cfg.enable { 34 | boot = { 35 | initrd.systemd.enable = lib.mkDefault true; 36 | 37 | kernel.sysctl = { 38 | # Enable Magic keys 39 | "kernel.sysrq" = 1; 40 | # https://wiki.archlinux.org/title/Zram#Optimizing_swap_on_zram 41 | "vm.swappiness" = lib.mkIf cfg.zram.enable 180; 42 | "vm.watermark_boost_factor" = lib.mkIf cfg.zram.enable 0; 43 | "vm.watermark_scale_factor" = lib.mkIf cfg.zram.enable 125; 44 | "vm.page-cluster" = lib.mkIf cfg.zram.enable 0; 45 | }; 46 | 47 | # Disable boot editor for security 48 | loader.systemd-boot.editor = false; 49 | 50 | # Enable NTFS support 51 | supportedFilesystems = [ "ntfs" ]; 52 | 53 | tmp = { 54 | # Mount /tmp using tmpfs for performance 55 | useTmpfs = lib.mkDefault true; 56 | # If not using above, at least clean /tmp on each boot 57 | cleanOnBoot = lib.mkDefault true; 58 | }; 59 | }; 60 | 61 | # Enable firmware-linux-nonfree 62 | hardware.enableRedistributableFirmware = lib.mkDefault true; 63 | 64 | # Enable nftables-based firewall 65 | networking.nftables.enable = lib.mkDefault true; 66 | 67 | services = { 68 | cron.enable = true; 69 | 70 | # Trim SSD weekly 71 | fstrim = { 72 | enable = true; 73 | interval = "weekly"; 74 | }; 75 | 76 | zram-generator = { 77 | inherit (cfg.zram) enable; 78 | settings.zram0 = { 79 | zram-size = lib.mkDefault "min(ram / 2, 4096)"; 80 | compression-algorithm = lib.mkDefault "zstd"; 81 | }; 82 | }; 83 | }; 84 | 85 | systemd = { 86 | # systemd's out-of-memory daemon 87 | oomd = { 88 | enableRootSlice = true; 89 | enableUserSlices = true; 90 | }; 91 | }; 92 | 93 | system = { 94 | # Enable NixOS auto-upgrade 95 | autoUpgrade = { 96 | enable = lib.mkDefault true; 97 | flake = "github:thiagokokada/nix-configs"; 98 | persistent = true; 99 | # Not enabled by default for desktop/laptops, see nixos.server 100 | # allowReboot = true; 101 | }; 102 | configurationRevision = flake.rev or "dirty"; 103 | }; 104 | 105 | # nixos/modules/misc/version.nix 106 | users.motd = lib.mkIf cfg.motd.enable '' 107 | Welcome to '${config.networking.hostName}' running NixOS ${config.system.nixos.version}! 108 | ''; 109 | }; 110 | } 111 | -------------------------------------------------------------------------------- /lib/flake-helpers.nix: -------------------------------------------------------------------------------- 1 | { 2 | self, 3 | nixpkgs, 4 | nix-darwin, 5 | home-manager, 6 | ... 7 | }: 8 | 9 | let 10 | setDefaultHostName = 11 | hostName: 12 | ( 13 | { lib, ... }: 14 | { 15 | networking.hostName = lib.mkDefault hostName; 16 | } 17 | ); 18 | specialArgs = { 19 | flake = self; 20 | libEx = self.outputs.lib; 21 | }; 22 | in 23 | { 24 | mkNixOSConfig = 25 | { 26 | hostName, 27 | configuration, 28 | }: 29 | let 30 | inherit (self.outputs.nixosConfigurations.${hostName}) config pkgs; 31 | inherit (config.system.build) nixos-rebuild; 32 | in 33 | { 34 | nixosConfigurations.${hostName} = nixpkgs.lib.nixosSystem { 35 | inherit specialArgs; 36 | modules = [ 37 | (setDefaultHostName hostName) 38 | self.outputs.nixosModules.default 39 | configuration 40 | ]; 41 | }; 42 | 43 | apps.${pkgs.stdenv.hostPlatform.system} = { 44 | "nixosActivations/${hostName}" = { 45 | type = "app"; 46 | program = nixpkgs.lib.getExe ( 47 | pkgs.writeShellScriptBin "activate" '' 48 | sudo ${pkgs.lib.getExe nixos-rebuild} switch --flake '${self}#${hostName}' 49 | '' 50 | ); 51 | meta.description = "NixOS activation script for ${hostName}"; 52 | }; 53 | }; 54 | }; 55 | 56 | mkNixDarwinConfig = 57 | { 58 | hostName, 59 | configuration, 60 | }: 61 | let 62 | inherit (self.outputs.darwinConfigurations.${hostName}) pkgs config; 63 | inherit (config.system.build) darwin-rebuild; 64 | in 65 | { 66 | darwinConfigurations.${hostName} = nix-darwin.lib.darwinSystem { 67 | inherit specialArgs; 68 | modules = [ 69 | (setDefaultHostName hostName) 70 | self.outputs.darwinModules.default 71 | configuration 72 | ]; 73 | }; 74 | 75 | apps.${pkgs.stdenv.hostPlatform.system} = { 76 | "darwinActivations/${hostName}" = { 77 | type = "app"; 78 | program = nixpkgs.lib.getExe ( 79 | pkgs.writeShellScriptBin "activate" '' 80 | sudo ${pkgs.lib.getExe darwin-rebuild} switch --flake '${self}#${hostName}' 81 | '' 82 | ); 83 | meta.description = "nix-darwin activation script for ${hostName}"; 84 | }; 85 | }; 86 | }; 87 | 88 | mkHomeConfig = 89 | { 90 | hostName, 91 | configuration, 92 | system, 93 | }: 94 | { 95 | homeConfigurations.${hostName} = home-manager.lib.homeManagerConfiguration { 96 | pkgs = self.outputs.legacyPackages.${system}; 97 | modules = [ 98 | self.outputs.homeModules.default 99 | configuration 100 | ]; 101 | extraSpecialArgs = specialArgs; 102 | }; 103 | 104 | apps.${system}."homeActivations/${hostName}" = { 105 | type = "app"; 106 | program = "${self.outputs.homeConfigurations.${hostName}.activationPackage}/activate"; 107 | meta.description = "Home activation script for ${hostName}"; 108 | }; 109 | }; 110 | } 111 | -------------------------------------------------------------------------------- /modules/nixos/system/gpu.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.nixos.system.gpu; 10 | inherit (cfg) maker; 11 | in 12 | { 13 | options.nixos.system.gpu = { 14 | maker = lib.mkOption { 15 | type = lib.types.nullOr ( 16 | lib.types.enum [ 17 | "amd" 18 | "intel" 19 | "nvidia" 20 | ] 21 | ); 22 | default = null; 23 | description = "GPU maker."; 24 | }; 25 | acceleration.enable = lib.mkEnableOption "CUDA/ROCm support"; 26 | }; 27 | 28 | config = lib.mkMerge [ 29 | (lib.mkIf (maker == "amd") { 30 | hardware = { 31 | # Needed for lact 32 | amdgpu.overdrive.enable = true; 33 | # OpenCL for AMD GPUs 34 | graphics.extraPackages = 35 | with pkgs; 36 | lib.mkIf cfg.acceleration.enable [ 37 | rocmPackages.clr.icd 38 | ]; 39 | }; 40 | 41 | programs.gamemode = { 42 | settings.gpu = { 43 | apply_gpu_optimisations = "accept-responsibility"; 44 | # Override this in host for multi-GPU systems 45 | gpu_device = lib.mkDefault 0; 46 | amd_performance_level = "high"; 47 | }; 48 | }; 49 | }) 50 | (lib.mkIf (maker == "amd" && cfg.acceleration.enable) { 51 | # Enable support for ROCm in nixpkgs 52 | nixpkgs.config.rocmSupport = true; 53 | 54 | # OpenCL for AMD GPUs 55 | hardware.graphics.extraPackages = with pkgs; [ 56 | rocmPackages.clr.icd 57 | ]; 58 | 59 | # ROCm packages 60 | systemd.tmpfiles.rules = 61 | let 62 | rocmEnv = pkgs.symlinkJoin { 63 | name = "rocm-combined"; 64 | paths = with pkgs.rocmPackages; [ 65 | rocblas 66 | hipblas 67 | clr 68 | ]; 69 | }; 70 | in 71 | [ "L+ /opt/rocm - - - - ${rocmEnv}" ]; 72 | }) 73 | ( 74 | let 75 | inherit (config.hardware.nvidia.prime.offload) offloadCmdMainProgram; 76 | primeEnabled = 77 | config.hardware.nvidia.prime.offload.enable || config.hardware.nvidia.prime.reverseSync.enable; 78 | in 79 | lib.mkIf (maker == "nvidia") { 80 | nixos.home.extraModules = { 81 | home-manager.window-manager.x11.nvidia = { 82 | enable = true; 83 | prime = { 84 | sync = { inherit (config.hardware.nvidia.prime.sync) enable; }; 85 | offload = { inherit (config.hardware.nvidia.prime.offload) enable; }; 86 | }; 87 | }; 88 | }; 89 | 90 | # Use nvidia-offload script in gamemode 91 | environment.variables.GAMEMODERUNEXEC = lib.mkIf primeEnabled "/run/current-system/sw/bin/${offloadCmdMainProgram}"; 92 | 93 | hardware.nvidia.prime.offload.enableOffloadCmd = primeEnabled; 94 | } 95 | ) 96 | (lib.mkIf (maker == "nvidia" && cfg.acceleration.enable) { 97 | # Enable support for CUDA in nixpkgs 98 | nixpkgs.config.cudaSupport = true; 99 | }) 100 | (lib.mkIf (maker != null) { 101 | # GPU control application 102 | services.lact.enable = config.nixos.desktop.enable; 103 | }) 104 | ]; 105 | } 106 | -------------------------------------------------------------------------------- /modules/nixos/server/rtorrent.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: 7 | 8 | let 9 | inherit (config.device.media) directory; 10 | inherit (config.nixos.home) username; 11 | cfg = config.nixos.server.rtorrent; 12 | in 13 | { 14 | options.nixos.server.rtorrent = { 15 | enable = lib.mkEnableOption "rTorrent config"; 16 | ratio = { 17 | enable = lib.mkEnableOption "ratio control"; 18 | min = lib.mkOption { 19 | type = lib.types.int; 20 | description = "Minimum ratio (if size is reached)."; 21 | default = 200; 22 | }; 23 | max = lib.mkOption { 24 | description = "Maximum ratio (if size is not reached)."; 25 | type = lib.types.int; 26 | default = 300; 27 | }; 28 | size = lib.mkOption { 29 | description = "Upload size that should be reached."; 30 | type = lib.types.str; 31 | default = "500M"; 32 | }; 33 | }; 34 | flood.enable = lib.mkEnableOption "Flood UI" // { 35 | default = true; 36 | }; 37 | }; 38 | 39 | config = 40 | with config.users.users.${username}; 41 | lib.mkIf cfg.enable { 42 | environment.systemPackages = with pkgs; [ rtorrent ]; 43 | 44 | services = { 45 | flood = { 46 | inherit (cfg.flood) enable; 47 | host = "::"; 48 | openFirewall = true; 49 | extraArgs = [ "--rtsocket=${config.services.rtorrent.rpcSocket}" ]; 50 | }; 51 | rtorrent = { 52 | inherit (cfg) enable; 53 | inherit group; 54 | downloadDir = "${directory}/Downloads"; 55 | user = username; 56 | port = 60001; 57 | openFirewall = true; 58 | configText = '' 59 | ${lib.optionalString cfg.ratio.enable '' 60 | # Enable the default ratio group. 61 | ratio.enable= 62 | 63 | # Change the limits, the defaults should be sufficient. 64 | ratio.min.set=${toString cfg.ratio.min} 65 | ratio.max.set=${toString cfg.ratio.max} 66 | ratio.upload.set=${cfg.ratio.size} 67 | ''} 68 | 69 | ${lib.optionalString cfg.flood.enable '' 70 | method.redirect=load.throw,load.normal 71 | method.redirect=load.start_throw,load.start 72 | method.insert=d.down.sequential,value|const,0 73 | method.insert=d.down.sequential.set,value|const,0 74 | ''} 75 | 76 | # Watch directory 77 | schedule2 = watch_directory,5,5,load.start="${directory}/Torrents/*.torrent" 78 | schedule2 = untied_directory,5,5,stop_untied= 79 | 80 | # Disable when diskspace is low 81 | schedule2 = monitor_diskspace, 15, 60, ((close_low_diskspace, 1000M)) 82 | 83 | # Set umask for download files 84 | system.umask.set = 0002 85 | ''; 86 | }; 87 | }; 88 | 89 | systemd.services = { 90 | flood.serviceConfig = { 91 | SupplementaryGroups = [ group ]; 92 | }; 93 | }; 94 | 95 | systemd.tmpfiles.rules = [ 96 | "d ${directory}/Downloads 2775 ${username} ${group}" 97 | "d ${directory}/Torrents 2775 ${username} ${group}" 98 | ]; 99 | }; 100 | } 101 | -------------------------------------------------------------------------------- /modules/nixos/games/jovian.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | flake, 6 | ... 7 | }: 8 | 9 | let 10 | inherit (config.nixos.home) username; 11 | cfg = config.nixos.games.jovian; 12 | in 13 | { 14 | imports = [ 15 | flake.inputs.jovian-nixos.nixosModules.default 16 | # TODO: move this somewhere else 17 | flake.inputs.nix-flatpak.nixosModules.nix-flatpak 18 | ]; 19 | 20 | options.nixos.games.jovian = { 21 | enable = lib.mkEnableOption "Jovian-NixOS config" // { 22 | default = config.device.type == "steam-machine"; 23 | }; 24 | bootInDesktopMode = lib.mkEnableOption "boot in desktop mode"; 25 | }; 26 | 27 | config = lib.mkIf cfg.enable { 28 | nixos.home.extraModules = { 29 | home.file."Desktop/Return-to-Gaming-Mode.desktop".source = 30 | (pkgs.makeDesktopItem { 31 | desktopName = "Return to Gaming Mode"; 32 | exec = "qdbus org.kde.Shutdown /Shutdown org.kde.Shutdown.logout"; 33 | icon = "steam"; 34 | name = "Return-to-Gaming-Mode"; 35 | startupNotify = false; 36 | terminal = false; 37 | type = "Application"; 38 | }) 39 | + "/share/applications/Return-to-Gaming-Mode.desktop"; 40 | 41 | # Automatically mount disks in Gamescope session 42 | services.udiskie = { 43 | enable = lib.mkDefault true; 44 | # Assuming KDE here, we will already have notifications from it 45 | notify = lib.mkDefault false; 46 | # Disable tray otherwise this service depends on tray.target (that 47 | # Gamescope session does not start) 48 | tray = "never"; 49 | }; 50 | 51 | xdg.stateFile."steamos-session-select" = lib.mkIf cfg.bootInDesktopMode { 52 | text = config.jovian.steam.desktopSession; 53 | }; 54 | }; 55 | 56 | jovian = { 57 | steam = { 58 | enable = true; 59 | autoStart = true; 60 | user = username; 61 | desktopSession = config.services.displayManager.defaultSession; 62 | environment = { 63 | STEAM_EXTRA_COMPAT_TOOLS_PATHS = 64 | lib.makeSearchPathOutput "steamcompattool" "" 65 | config.programs.steam.extraCompatPackages; 66 | }; 67 | }; 68 | hardware.has.amd.gpu = config.nixos.system.gpu.maker == "amd"; 69 | }; 70 | 71 | programs.steam.extraCompatPackages = with pkgs; [ 72 | proton-ge-bin 73 | ]; 74 | 75 | services.flatpak = { 76 | enable = lib.mkDefault true; 77 | packages = [ 78 | "com.heroicgameslauncher.hgl" 79 | "net.retrodeck.retrodeck" 80 | ]; 81 | update.auto.enable = true; 82 | }; 83 | 84 | specialisation = { 85 | game-mode = lib.mkIf cfg.bootInDesktopMode { 86 | configuration = { 87 | boot.loader.systemd-boot.sortKey = "o_nixos"; 88 | nixos.games.jovian.bootInDesktopMode = false; 89 | system.nixos.tags = [ "with-jovian-in-game-mode" ]; 90 | }; 91 | }; 92 | desktop-mode = lib.mkIf (!cfg.bootInDesktopMode) { 93 | configuration = { 94 | boot.loader.systemd-boot.sortKey = "o_nixos"; 95 | nixos.games.jovian.bootInDesktopMode = true; 96 | system.nixos.tags = [ "with-jovian-in-desktop-mode" ]; 97 | }; 98 | }; 99 | }; 100 | }; 101 | } 102 | -------------------------------------------------------------------------------- /packages/nix-cleanup/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | lib, 3 | coreutils, 4 | findutils, 5 | gawk, 6 | gnugrep, 7 | home-manager, 8 | nix, 9 | writeShellApplication, 10 | isNixOS ? false, 11 | isNixDarwin ? false, 12 | }: 13 | 14 | writeShellApplication { 15 | name = 16 | if isNixOS then 17 | "nixos-cleanup" 18 | else if isNixDarwin then 19 | "darwin-cleanup" 20 | else 21 | "nix-cleanup"; 22 | 23 | runtimeInputs = [ 24 | coreutils 25 | findutils 26 | gawk 27 | gnugrep 28 | home-manager 29 | nix 30 | ]; 31 | text = # bash 32 | '' 33 | AUTO=0 34 | OPTIMIZE=0 35 | HM_PROFILE=0 36 | 37 | usage() { 38 | echo "Clean-up /nix/store." 39 | echo 40 | echo "Usage:" 41 | echo "$(basename "$0") [--hm-profiles] [--auto] [--optimize]" 42 | echo 43 | echo "Arguments:" 44 | echo " --hm-profiles Remove home-manager profiles." 45 | echo " --auto Remove auto created gc-roots (e.g.: '/result' symlinks)." 46 | echo " --optimize Run 'nix-store --optimize' afterwards." 47 | exit 1 48 | } 49 | 50 | while [[ ''${#:-0} -gt 0 ]]; do 51 | case "$1" in 52 | -h|--help) 53 | usage 54 | ;; 55 | --auto) 56 | AUTO=1 57 | shift 58 | ;; 59 | --optimize) 60 | OPTIMIZE=1 61 | shift 62 | ;; 63 | --hm-profiles) 64 | HM_PROFILE=1 65 | shift 66 | ;; 67 | *) 68 | echo "'$1' is not a recognized flag!" 69 | exit 1; 70 | ;; 71 | esac 72 | done 73 | 74 | cleanup_hm() { 75 | local -r hm_profile="$1" 76 | 77 | if [[ "$hm_profile" == 1 ]]; then 78 | echo "[INFO] Clean-up old home-manager generations..." 79 | home-manager expire-generations '0 days' 80 | fi 81 | } 82 | 83 | cleanup() { 84 | local -r auto="$1" 85 | local -r optimize="$2" 86 | 87 | if [[ "$auto" == 1 ]]; then 88 | echo "[INFO] Removing auto created GC roots..." 89 | nix-store --gc --print-roots | \ 90 | awk '{ print $1 }' | \ 91 | grep '/result.*$' | \ 92 | xargs -L1 rm -rf || true 93 | fi 94 | 95 | echo "[INFO] Running GC..." 96 | nix-collect-garbage -d 97 | 98 | echo "[INFO] Verifying nix store..." 99 | nix-store --verify 100 | 101 | if [[ "$optimize" == 1 ]]; then 102 | echo "[INFO] Optimizing nix store..." 103 | nix-store --optimize 104 | fi 105 | 106 | ${lib.optionalString isNixOS 107 | # bash 108 | '' 109 | echo "[INFO] Rebuilding NixOS to remove old boot entries..." 110 | /run/current-system/bin/switch-to-configuration boot 111 | '' 112 | } 113 | } 114 | 115 | cleanup_hm "$HM_PROFILE" 116 | ${ 117 | if isNixOS || isNixDarwin then 118 | # bash 119 | '' 120 | sudo bash -lc "$(declare -f cleanup); cleanup $AUTO $OPTIMIZE" 121 | '' 122 | else 123 | # bash 124 | '' 125 | cleanup "$AUTO" "$OPTIMIZE" 126 | '' 127 | } 128 | ''; 129 | } 130 | -------------------------------------------------------------------------------- /modules/home-manager/window-manager/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | lib, 5 | ... 6 | }: 7 | 8 | let 9 | cfg = config.home-manager.window-manager; 10 | in 11 | { 12 | imports = [ 13 | ./dunst.nix 14 | ./gammastep.nix 15 | ./theme 16 | ./wayland 17 | ./x11 18 | ]; 19 | 20 | options.home-manager.window-manager = { 21 | enable = lib.mkEnableOption "window manager config"; 22 | default = { 23 | browser = lib.mkOption { 24 | type = lib.types.str; 25 | description = "Default web browser to be used."; 26 | default = lib.getExe config.programs.firefox.finalPackage; 27 | }; 28 | editor = lib.mkOption { 29 | type = lib.types.str; 30 | description = "Default editor to be used."; 31 | default = lib.getExe config.programs.neovim.finalPackage; 32 | }; 33 | fileManager = lib.mkOption { 34 | type = lib.types.str; 35 | description = "Default file manager to be used."; 36 | default = "${cfg.default.terminal} -- ${lib.getExe config.programs.yazi.package}"; 37 | }; 38 | volumeControl = lib.mkOption { 39 | type = lib.types.str; 40 | description = "Default volume control to be used."; 41 | default = lib.getExe pkgs.pwvucontrol; 42 | }; 43 | terminal = lib.mkOption { 44 | type = lib.types.str; 45 | description = '' 46 | Default terminal emulator to be used. 47 | 48 | Should allow starting programs as parameter. 49 | ''; 50 | default = lib.getExe config.programs.kitty.package; 51 | }; 52 | }; 53 | systemd.service = { 54 | # Use exponential restart 55 | # https://enotty.pipebreaker.pl/posts/2024/01/how-systemd-exponential-restart-delay-works/ 56 | RestartSec = lib.mkOption { 57 | type = lib.types.str; 58 | description = "How long to wait between restarts."; 59 | default = "250ms"; 60 | }; 61 | RestartSteps = lib.mkOption { 62 | type = lib.types.int; 63 | description = "Number of steps to take to increase the interval of auto-restarts."; 64 | default = 5; 65 | }; 66 | RestartMaxDelaySec = lib.mkOption { 67 | type = lib.types.str; 68 | description = "Longest time to sleep before restarting a service as the interval goes up."; 69 | default = "5s"; 70 | }; 71 | }; 72 | }; 73 | 74 | config = lib.mkIf cfg.enable { 75 | home.packages = with pkgs; [ 76 | desktop-file-utils 77 | evince 78 | file-roller 79 | gnome-disk-utility 80 | gthumb 81 | (nemo-with-extensions.override { extensions = [ nemo-fileroller ]; }) 82 | pamixer 83 | pwvucontrol 84 | playerctl 85 | qalculate-gtk 86 | ]; 87 | 88 | services.udiskie.enable = true; 89 | 90 | xdg = { 91 | # Some applications like to overwrite this file, so let's just force it 92 | configFile."mimeapps.list".force = true; 93 | 94 | mimeApps = { 95 | enable = true; 96 | defaultApplications = { 97 | "application/pdf" = "org.gnome.Evince.desktop"; 98 | "image/gif" = "org.gnome.gThumb.desktop"; 99 | "image/jpeg" = "org.gnome.gThumb.desktop"; 100 | "image/png" = "org.gnome.gThumb.desktop"; 101 | "inode/directory" = "nemo.desktop"; 102 | "text/html" = "firefox.desktop"; 103 | "text/plain" = "nvim.desktop"; 104 | "text/x-makefile" = "nvim.desktop"; 105 | "x-scheme-handler/about" = "firefox.desktop"; 106 | "x-scheme-handler/http" = "firefox.desktop"; 107 | "x-scheme-handler/https" = "firefox.desktop"; 108 | "x-scheme-handler/unknown" = "firefox.desktop"; 109 | }; 110 | }; 111 | 112 | userDirs = { 113 | enable = true; 114 | createDirectories = true; 115 | }; 116 | }; 117 | }; 118 | } 119 | --------------------------------------------------------------------------------