nix.ffloyd.space

This personal Nix configuration defines 2 hosts and 12 aspects.

framework-13-amd-ai-300

Hostname
framework13
OS type
nixos
Architecture
x86_64-linux

Enabled aspects (12)

base
Foundational NixOS, Home Manager and System Manager configurations.
Features (22)
shell
Bash login environment, Nushell sessions, and CLI quality-of-life tools.
Features (13)
terminal
Terminal emulator configuration
Features (1)
gpg
GPG configuration and shell helpers
Features (2)
development
Comprehensive development environment
Features (19)
server-management
Configs and helpers to manage my personal VPS
Features (3)
desktop-apps
Desktop applications tailored to my workflows.
Features (2)
noctalia-5-desktop
Niri and Noctalia v5 desktop environment with its greeter
Features (6)
browser
Web browser and related tools
Features (3)
gaming
Gaming-related tools and configurations
Features (3)
music-making
Enables music making on NixOS
Features (2)
reverse-proxy
Local reverse proxy
Features (1)

Host-specific adjustments (16)

ubuntu-work

Hostname
T14
OS type
ubuntu
Architecture
x86_64-linux

Enabled aspects (8)

base
Foundational NixOS, Home Manager and System Manager configurations.
Features (6)
shell
Bash login environment, Nushell sessions, and CLI quality-of-life tools.
Features (12)
terminal
Terminal emulator configuration
Features (1)
development
Comprehensive development environment
Features (17)
gpg
GPG configuration and shell helpers
Features (1)
desktop-apps
Desktop applications tailored to my workflows.
Features (1)
noctalia-5-desktop
Niri and Noctalia v5 desktop environment with its greeter
Features (5)
browser
Web browser and related tools
Features (3)

Host-specific adjustments (7)

Where the heck am I?

This is an autogenerated overview of my personal Nix configuration. It's responsible for OS settings, installed software, dotfiles and more.

Term Meaning
Host A machine I have.
Aspect A bundle of configurations that provides a capability to a host.
Feature Something an aspect provides.
Adjustment A host-specific piece of configuration.

source button near host or aspect opens file where hosts or aspect is defined. Click on an aspect to see its description and features applied to the host. Click on feature or adjustment to see file where the feature or adjustment is defined.

Caption of source code modals has a link to the same file on Codeberg if you want to explore surroundings. E. g. config files that a feature implementation refers to.

With Nix installed and flakes enabled you can even build this website locally without cloning the repo:

nix build git+https://codeberg.org/ffloyd/nix#website
xdg-open result/index.html # or what you do on MacOS

If you want to make your configuration using the same machinery, let me know via hi@ffloyd.space. Then I may extract it as a flake.parts module (including website generation).

aspects/base/a_meta.nix

{
  my.aspects.base = {
    description = "Foundational NixOS, Home Manager and System Manager configurations.";
  };
}

aspects/base/agenix.nix

{inputs, ...}: {
  my.aspects.base = {
    features = [
      ["nixos" "OS-level Agenix (age-encrypted secrets)"]
      ["common" "Agenix for Home Manager (age-encrypted secrets)"]
    ];

    nixos = {
      config,
      system,
      username,
      pkgs,
      ...
    }: {
      imports = [
        inputs.agenix.nixosModules.default
      ];

      age = {
        identityPaths = ["/home/${username}/.ssh/id_ed25519"];
        secrets.test.file = ./agenix/test.age;
      };

      environment.systemPackages = [
        inputs.agenix.packages.${system}.default

        (pkgs.writeShellScriptBin "os-agenix-test" ''
          echo "Test secret path: ${config.age.secrets.test.path}"
          echo "Test secret content:"
          cat ${config.age.secrets.test.path}
        '')
      ];
    };

    home = {
      config,
      system,
      pkgs,
      ...
    }: {
      imports = [
        inputs.agenix.homeManagerModules.default
      ];

      age = {
        identityPaths = ["${config.home.homeDirectory}/.ssh/id_ed25519"];
        secretsDir = "${config.home.homeDirectory}/.secrets";
        secrets = {
          test.file = ./agenix/test.age;
        };
      };

      home.packages = [
        inputs.agenix.packages.${system}.default

        (pkgs.writeShellScriptBin "hm-agenix-test" ''
          echo "Test secret path: ${config.age.secrets.test.path}"
          echo "Test secret content:"
          cat ${config.age.secrets.test.path}
        '')
      ];
    };
  };
}

aspects/base/appimage.nix

{inputs, ...}: {
  my.aspects.base = {
    features = [
      ["nixos" "AppImage support"]
    ];

    nixos = {
      programs.appimage = {
        enable = true;
        binfmt = true;
      };
    };
  };
}

aspects/base/flatpak.nix

{inputs, ...}: {
  my.aspects.base = {
    features = [
      ["nixos" "Flatpak support"]
    ];

    nixos = {
      services.flatpak.enable = true;
    };

    homeNixos = {pkgs, ...}: {
      imports = [inputs.nix-flatpak.homeManagerModules.nix-flatpak];

      home.packages = [pkgs.flatpak];
    };
  };
}

aspects/base/fonts.nix

{
  my.aspects.base = let
    fontListFrom = pkgs:
      with pkgs; [
        # My favorite font, highly recommend it
        # https://typeof.net/Iosevka/
        nerd-fonts.iosevka-term
        nerd-fonts.iosevka
        (iosevka-bin.override {variant = "SS10";})
        (iosevka-bin.override {variant = "Etoile";})
        (iosevka-bin.override {variant = "Aile";})
      ];
  in {
    features = [
      ["nixos" "System-wide font installation"]
      ["ubuntu" "User font installation with Fontconfig"]
    ];

    nixos = {pkgs, ...}: {
      fonts = {
        enableDefaultPackages = true;
        packages = fontListFrom pkgs;
      };
    };

    homeUbuntu = {pkgs, ...}: {
      fonts.fontconfig.enable = true;
      home.packages = fontListFrom pkgs;
    };
  };
}

aspects/base/locale.nix

{config, ...}: let
  inherit (config.my.consts) timezone locale extraLocale;
in {
  my.aspects.base = {
    features = [
      ["nixos" "Timezone and locale settings"]
    ];

    nixos = {
      time.timeZone = timezone;
      i18n.defaultLocale = locale;

      i18n.extraLocaleSettings = {
        LC_ADDRESS = extraLocale;
        LC_IDENTIFICATION = extraLocale;
        LC_MEASUREMENT = extraLocale;
        LC_MONETARY = extraLocale;
        LC_NAME = extraLocale;
        LC_NUMERIC = extraLocale;
        LC_PAPER = extraLocale;
        LC_TELEPHONE = extraLocale;
        LC_TIME = extraLocale;
      };
    };
  };
}

aspects/base/network.nix

{
  my.aspects.base = {
    features = [
      ["nixos" "NetworkManager"]
      ["nixos" "OpenSSH server"]
      ["nixos" "Firewall"]
    ];

    nixos = {
      hostname,
      username,
      ...
    }: {
      networking.hostName = hostname;

      networking.networkmanager.enable = true;
      users.users.${username}.extraGroups = ["networkmanager"];

      services.openssh = {
        enable = true;
        settings = {
          # Only key-based authentication for local users.
          PasswordAuthentication = false;
          PermitRootLogin = "no";
        };
      };

      networking.firewall = {
        enable = true;

        allowedTCPPorts = [
          5173 # Vite dev server
        ];
      };
    };
  };
}

aspects/base/nix.nix

{inputs, ...}: {
  my.aspects.base = let
    enabledNixExperimentalFeatures = ["nix-command" "flakes"];
  in {
    features = [
      ["nixos" "nixos-cli as a convinient wrapper for nixos-rebuild, etc."]
      ["nixos" "Nix inspection tools (nix-tree, nix-inspect)"]
      ["nixos" "Use Determinate Nix"]
      ["common" "Common Nix settings"]
      ["common" "Nix MCP server"]
      ["common" "Shared shell aliases for common operations"]
      ["ubuntu" "Nushell helper for system-manager and Home Manager rebuilds"]
    ];

    nixos = {
      pkgs,
      system,
      username,
      ...
    }: {
      imports = [
        inputs.nixos-cli.nixosModules.nixos-cli
        inputs.determinate.nixosModules.default
      ];

      programs.nixos-cli = {
        enable = true;
        # unwrapped variant of the package forces Determinate Nix usage
        # (default package has classic `nix` baked in)
        package = inputs.nixos-cli.packages.${system}.nixos-cli-unwrapped;
        settings = {
          config_location = "/home/${username}/nix";
          differ.command = ["nvd" "diff"];
          apply.use_nom = true;
        };
      };

      nix.settings = {
        experimental-features = enabledNixExperimentalFeatures;
        substituters = ["https://watersucks.cachix.org"];
        trusted-public-keys = [
          "watersucks.cachix.org-1:6gadPC5R8iLWQ3EUtfu3GFrVY7X6I4Fwz/ihW25Jbv8="
        ];
        # Allow user to use nix features that require elevated privileges
        trusted-users = ["root" username];
      };

      environment.systemPackages = [
        inputs.nix-inspect.packages.${system}.default
        pkgs.nix-tree

        # used by nixos-cli
        inputs.nix-output-monitor.packages.${system}.default
        pkgs.nvd
      ];
    };

    home = {
      pkgs,
      lib,
      ...
    }: {
      programs.mcp.servers.mcp-nix = {
        enabled = true;
        # nixpkgs defaults to MCP SDK 2, which breaks this server's FastMCP 3 dependency.
        # Limit the SDK downgrade to this server so unrelated Python applications are unaffected.
        # Track the FastMCP 4 update and related migration work:
        # https://github.com/NixOS/nixpkgs/pull/563493
        # https://github.com/NixOS/nixpkgs/pull/568727
        # Remove once the fix reaches our locked nixpkgs and unmodified mcp-nixos builds.
        command = lib.getExe (pkgs.mcp-nixos.override {
          python3Packages = pkgs.python3Packages.overrideScope (_final: prev: {
            mcp = prev.mcp_1;
          });
        });
      };
    };

    homeNixos = {
      home.shellAliases = {
        os-rebuild = "nixos apply --local-root";
        os-rebuild-boot = "nixos apply --no-activate --install-bootloader";
        os-gc = "nixos generation delete --min 5 --all";
        ",nix-search-exec" = "nix-env -qaP";
      };
    };

    ubuntu = {
      pkgs,
      username,
      ...
    }: {
      environment.etc."nix/nix.custom.conf".text = ''
        # Core Nix configs
        extra-experimental-features = ${pkgs.lib.strings.join " " enabledNixExperimentalFeatures}
        trusted-users = root ${username}
      '';

      environment.systemPackages = [pkgs.system-manager];
    };

    homeUbuntu = {
      xdg.mime.enable = true;
      home.activation = {
        # TODO: it's better to create a separate folder and copy from derivation
        # to it and add that folder to desktop-database.
        # The downside of that approcah - we need to wipe the folder
        # each time beacuse otherwise stale desktop links will be persisted.
        linkDesktopApplications = {
          after = ["writeBoundary" "createXdgUserDirectories"];
          before = [];
          data = "/usr/bin/sudo /usr/bin/chmod -R 777 $HOME/.nix-profile/share/applications && /usr/bin/update-desktop-database $HOME/.nix-profile/share/applications";
        };
      };

      home.shellAliases = {
        ",nix-search-exec" = "nix-env -qaP";
      };

      programs.nushell.extraConfig =
        # nu
        ''
          # Applies the Ubuntu system and/or Home Manager configuration, defaulting to both.
          #
          # Expects ~/nix to contain the configuration and the selected manager commands on PATH.
          def os-rebuild [target: string = "all"] {
            if $target not-in [all hm sys] {
              error make $"Invalid rebuild target '($target)'. Expected all, hm, or sys."
            }

            if $target in [all sys] {
              ^system-manager switch --flake ~/nix --sudo
            }

            if $target in [all hm] {
              ^home-manager switch --flake ~/nix
            }
          }
        '';
    };
  };
}

aspects/base/printing.nix

{
  my.aspects.base = {
    features = [
      ["nixos" "CUPS printing"]
      ["nixos" "Support for Brother printers"]
      ["nixos" "Avahi for IPP printer discovery"]
    ];

    nixos = {
      pkgs,
      username,
      ...
    }: {
      services.printing = {
        enable = true;
        drivers = with pkgs; [
          gutenprint
          brgenml1lpr
          brgenml1cupswrapper
          cups-filters
          cups-browsed
        ];
      };

      # needed for IPP printers support
      services.avahi = {
        enable = true;
        nssmdns4 = true;
        openFirewall = true;
      };

      # otherwise CUPS can be slow
      services.colord.enable = true;

      # I want to be able to manage printers via CUPS web interface
      # without it I can do it, but UI is extremely slow for some reason
      users.users.${username}.extraGroups = ["lpadmin"];
    };
  };
}

aspects/base/root-env.nix

{
  my.aspects.base = {
    features = [
      ["nixos" "Neovim for root user"]
      ["nixos" "Essential CLI tools for root"]
    ];

    nixos = {pkgs, ...}: {
      # I want at least basic NeoVim be accessible to the root user
      # alongside with some essential CLI tools.
      programs.neovim = {
        enable = true;
        viAlias = true;
        vimAlias = true;
        defaultEditor = true;
      };

      environment.systemPackages = with pkgs; [
        bat
        wget
      ];
    };
  };
}

aspects/base/sound.nix

{
  my.aspects.base = {
    features = [
      ["nixos" "PipeWire with ALSA, JACK and PulseAudio compatibility"]
    ];

    nixos = {
      # Consider using pw-cli, pw-mon, pw-top, wpctl commands
      # for low-level inspection and control.
      security.rtkit.enable = true;

      services.pipewire = {
        enable = true;
        alsa.enable = true;
        alsa.support32Bit = true;
        pulse.enable = true;
        jack.enable = true;
      };
    };
  };
}

aspects/base/user.nix

{config, ...}: let
  inherit (config.my.consts) fullName;
in {
  my.aspects.base = {
    features = [
      ["nixos" "User account"]
    ];

    nixos = {username, ...}: {
      users.users.${username} = {
        isNormalUser = true;
        description = fullName;
        extraGroups = ["wheel"];
        packages = [];
      };
    };
  };
}

aspects/browser.nix

{inputs, ...}: {
  my.aspects.browser = {
    description = "Web browser and related tools";
    features = [
      ["common" "Zen browser with policies"]
      ["common" "Chromium package"]
      ["common" "Playwright MCP server"]
    ];

    # I need them both on NixOS and Ubuntu,
    # but if I ever add Darwin to the mix,
    # I'd probably use `homebrew` via `nix-darwin`
    # for Darwin hosts instead.
    home = {
      pkgs,
      lib,
      ...
    }: {
      imports = [
        inputs.zen-browser.homeModules.beta
      ];

      programs.zen-browser = {
        enable = true;

        policies = {
          DisableAppUpdate = true;
          DontCheckDefaultBrowser = false;

          # I'm using Proton Pass extension for this
          OfferToSaveLogins = false;
          AutofillAddressEnabled = false;
          AutofillCreditCardEnabled = false;
        };
      };

      home.packages = [
        pkgs.chromium
      ];

      programs.mcp.servers.playwright = {
        enabled = false;
        command = lib.getExe pkgs.playwright-mcp;
      };
    };
  };
}

aspects/desktop-apps/a_meta.nix

{
  my.aspects.desktop-apps = {
    description = "Desktop applications tailored to my workflows.";
    dependsOn = ["base"];
  };
}

aspects/desktop-apps/apps.nix

{
  my.aspects.desktop-apps = {
    features = [
      ["common" "Obsidian"]
      ["nixos" "Additional desktop apps and Flatpak packages"]
    ];

    nixos = {
      # to rule all my Mikrotik devices
      programs.winbox.enable = true;
    };

    home = {pkgs, ...}: {
      home.packages = [
        pkgs.obsidian
      ];
    };

    homeNixos = {pkgs, ...}: {
      services.flatpak.packages = [
        # not using it anymore, but haven't ported all the data
        "io.anytype.anytype"

        # I had crashes with the nixpkgs version
        "me.proton.Mail"

        # GUI to deal with Flatpak apps
        "io.github.flattool.Warehouse"
      ];

      home.packages = [
        # Unofficial non-Electron Tidal client
        pkgs.tonearm

        pkgs.libreoffice

        pkgs.proton-pass
        pkgs.proton-vpn

        pkgs.telegram-desktop
        pkgs.signal-desktop

        pkgs.vlc

        pkgs.gimp-with-plugins
      ];
    };
  };
}

aspects/development/a_meta.nix

{
  my.aspects.development = {
    description = "Comprehensive development environment";
  };
}

aspects/development/ai-agents.nix

{
  config,
  inputs,
  ...
}: let
  inherit (config.my.helpers) mkDirectSymlink;
in {
  my.aspects.development = {
    features = [
      ["common" "OpenCode configuration"]
      ["common" "Herd (both TUI & App)"]
    ];

    home = {
      lib,
      pkgs,
      config,
      system,
      ...
    }: let
      llmAgents = inputs.llm-agents.packages.${system};

      # llm-agents installs OpenCode 2 as `opencode2` to coexist with v1;
      # But other parts of system (e. g. sidekick.nvim) expects it as `opencode`.
      opencode =
        pkgs.runCommand "opencode-${llmAgents.opencode2.version}" {
          inherit (llmAgents.opencode2) version;
          meta = llmAgents.opencode2.meta // {mainProgram = "opencode";};
        } ''
          mkdir -p $out/bin
          ln -s ${lib.getExe llmAgents.opencode2} $out/bin/opencode
        '';
    in {
      age.secrets.kagi-api-key.file = ./ai-agents/kagi-api-key.age;
      age.secrets.ctx7-api-key.file = ./ai-agents/ctx7-key.age;

      xdg.configFile = {
        "opencode/commands".source = mkDirectSymlink config ./ai-agents/commands;
        "opencode/skills".source = mkDirectSymlink config ./ai-agents/skills;
      };

      home.packages = [
        pkgs.pi-coding-agent
        llmAgents.opencode2-desktop

        llmAgents.herdr
        llmAgents.herdr-core
        llmAgents.herdr-app
      ];

      programs.mcp = {
        enable = true;
        servers = {
          ctx7 = {
            enabled = true;
            url = "https://mcp.context7.com/mcp";
            headers = {
              Authorization = "Bearer {file:${config.age.secrets.ctx7-api-key.path}}";
            };
          };
          kagi = {
            enabled = true;
            command = "uvx";
            args = ["kagimcp"];
            env.KAGI_API_KEY.file = config.age.secrets.kagi-api-key.path;
            env.UV_PYTHON = "${pkgs.python3}/bin/python3";
          };
        };
      };

      programs.opencode = {
        enable = true;
        package = opencode;
        mutableSettings = true;
        extraPackages = with pkgs; [
          alejandra
          nodejs
          uv
          python3
        ];

        enableMcpIntegration = true;

        settings = {
          compaction.auto = false;
          model = "openai/gpt-6.1-sol";
          agents = {
            plan.model = "openai/gpt-6-astra";
            explore.model = "openai/gpt-6-luna";
          };
          policies = [
            {
              action = "provider.use";
              resource = "*";
              effect = "deny";
            }
            {
              action = "provider.use";
              resource = "openai";
              effect = "allow";
            }
            {
              action = "provider.use";
              resource = "opencode-go";
              effect = "allow";
            }
          ];
          # Keep binary upgrades reproducible through the flake.
          update = "disable";
        };

        cli = {
          theme = {
            name = "carbonfox";
            mode = "system";
          };
          diffs.wrap = "word";
          session = {
            sidebar = "hide";
            scrollbar = false;
            thinking = "hide";
          };
          animations = true;
          attention = {
            notifications = true;
            sound = true;
            volume = 1.0;
          };
        };
        context = ./ai-shared/coding-rules.md;
      };
    };
  };
}

aspects/development/delta.nix

{
  my.aspects.development = {
    features = [
      ["common" "Delta for enhanced git diffs"]
    ];

    home = {
      programs.delta = {
        enable = true;
        enableGitIntegration = true;

        options = {
          features = "decorations";
          side-by-side = true;
          relative-paths = true;
          line-numbers = false;
        };
      };
    };
  };
}

aspects/development/direnv.nix

{
  my.aspects.development = {
    features = [
      ["common" "Direnv with nix-direnv and Bash/Nushell integration"]
    ];

    home = {
      programs.direnv = {
        enable = true;
        enableBashIntegration = true;
        enableNushellIntegration = true;
        nix-direnv.enable = true;
      };
    };
  };
}

aspects/development/docker.nix

{
  my.aspects.development = {
    features = [
      ["common" "Docker client and inspection tools"]
      ["nixos" "Docker daemon and user access"]
    ];

    nixos = {username, ...}: {
      virtualisation.docker.enable = true;

      users.users.${username}.extraGroups = ["docker"];
    };

    home = {pkgs, ...}: {
      home.packages = with pkgs; [
        dive
        dry
        docker-client
      ];
    };
  };
}

aspects/development/docs.nix

{
  my.aspects.development = {
    features = [
      ["common" "Documentation lookup app"]
    ];

    home = {pkgs, ...}: {
      home.packages = [
        pkgs.zeal
      ];
    };
  };
}

aspects/development/faketime.nix

{
  my.aspects.development = {
    features = [
      ["common" "libfaketime for time overrides"]
    ];

    home = {pkgs, ...}: {
      home.packages = [
        pkgs.libfaketime
      ];
    };
  };
}

aspects/development/git.nix

{config, ...}: let
  inherit (config.my.consts) fullName;
in {
  my.aspects.development = {
    features = [
      ["common" "Git, SSH, and commit signing setup"]
    ];

    home = {
      email,
      gpgKey,
      ...
    }: {
      programs.ssh = {
        enable = true;
        enableDefaultConfig = false;
        settings."*" = {
          ForwardAgent = false;
          AddKeysToAgent = "no";
          Compression = false;
          ServerAliveInterval = 0;
          ServerAliveCountMax = 3;
          HashKnownHosts = false;
          UserKnownHostsFile = "~/.ssh/known_hosts";
          ControlMaster = "no";
          ControlPath = "~/.ssh/master-%r@%n:%p";
          ControlPersist = "no";
        };
      };

      programs.git = {
        enable = true;

        settings = {
          user.name = fullName;
          user.email = email;

          push.autoSetupRemote = true;
          init.defaultBranch = "main";
        };

        signing = {
          key = gpgKey;
          signByDefault = true;
          format = "openpgp";
        };
      };
    };
  };
}

aspects/development/github.nix

{
  my.aspects.development = {
    features = [
      ["common" "Github CLI"]
    ];

    home = {pkgs, ...}: {
      home.packages = with pkgs; [gh];
    };
  };
}

aspects/development/neovim.nix

{config, ...}: let
  inherit (config.my.helpers) mkDirectSymlink;
in {
  my.aspects.development = {
    features = [
      ["common" "Neovim, global language servers and formatters"]
      ["common" "Go MCP server"]
      ["common" "Terraform MCP server"]
      ["common" "ast-grep MCP server for structural code search"]
    ];

    home = {
      pkgs,
      lib,
      config,
      ...
    }: let
      neovim-npm-dir = ".neovim-npm";
      neovim-npm-dir-full = "${config.home.homeDirectory}/${neovim-npm-dir}";
      neovim-adjusted = pkgs.symlinkJoin {
        name = "neovim-adjusted";
        paths = [pkgs.neovim];
        nativeBuildInputs = [
          pkgs.makeWrapper
        ];
        # Some NeoVim plugins require Node.js to be available in PATH,
        # but I don't want to install it globally.
        postBuild = ''
          wrapProgram $out/bin/nvim \
            --prefix PATH : ${lib.makeBinPath [pkgs.nodejs]} \
            --prefix PATH : "${neovim-npm-dir-full}/bin" \
            --set NPM_CONFIG_PREFIX "~/${neovim-npm-dir}"
        '';
      };
    in {
      home.packages =
        [
          # I do not use programs.neovim because I want to have directly
          # editable configuration files places out of the Nix
          # store. Unfortunately, programs.neovim unconditionally generates
          # immutable configuration files.
          neovim-adjusted
        ]
        ++ (with pkgs; [
          # NeoVim runtime dependencies
          luajit
          fd
          ripgrep
          tree-sitter

          # optional by https://github.com/MagicDuck/grug-far.nvim
          ast-grep

          # required by snacks.nvim dashboard
          dwt1-shell-color-scripts

          # required by snacks.nvim image viewer
          imagemagick

          # required by sidekick.nvim
          lsof

          # Global Language Servers
          #
          # For me it's more convenient to have _these ones_ globally installed.
          #
          # For others I usually define language server in the scope of a development shell:
          # it makes development expirience more reproducible (especially for rarely visited projects).
          dockerfile-language-server
          gopls
          lua-language-server
          nixd
          pyright
          terraform-ls
          vscode-json-languageserver
          yaml-language-server

          # Linters/formatters
          commitlint
          djlint
          editorconfig-checker
          hadolint
          statix
        ]);

      programs.mcp.servers = {
        gopls = {
          enabled = false;
          command = lib.getExe pkgs.gopls;
          args = ["mcp"];
        };
        terraform = {
          enabled = false;
          command = lib.getExe pkgs.terraform-mcp-server;
          args = ["stdio"];
        };
        ast-grep = {
          enabled = true;
          command = lib.getExe pkgs.uv;
          args = [
            "tool"
            "run"
            "--from"
            # Pin the upstream server because it is not packaged in nixpkgs.
            "git+https://github.com/ast-grep/ast-grep-mcp@149e20d47bb7125fb0c1451feea2f48a98742034"
            "ast-grep-server"
          ];
          env = {
            UV_PYTHON = lib.getExe pkgs.python3;
            AST_GREP_PATH = lib.getExe pkgs.ast-grep;
          };
        };
      };

      home.file = {
        # Directory for installing NPM packages used by NeoVim plugins
        "${neovim-npm-dir}/.keep".text = "";

        # Direct symlink to my actual NeoVim configuration
        ".config/nvim".source = mkDirectSymlink config ./neovim/nvim;
      };

      home.sessionVariables.EDITOR = "nvim";
      programs.git.settings.core.editor = "nvim";

      home.shellAliases = {
        vimdiff = "nvim -d";
        vi = "nvim";
        vim = "nvim";
      };
    };

    homeNixos = {pkgs, ...}: {
      home.packages = [pkgs.gcc];
    };
  };
}

aspects/development/scripting.nix

{
  my.aspects.development = {
    features = [
      ["common" "CLI tooling for scripts"]
      ["common" "Proton Pass CLI"]
    ];

    home = {pkgs, ...}: {
      home.packages = with pkgs; [
        # data extraction & processing
        gawk
        jq
        wget

        # secrets management via pass
        (pass.withExtensions (exts: [exts.pass-otp]))

        # Proton Pass CLI
        proton-pass-cli
      ];
    };
  };
}

aspects/development/tidewave.nix

{config, ...}: {
  perSystem = {
    pkgs,
    system,
    lib,
    ...
  }: let
    version = "v1.1.0";
    longDescription = ''
      Develop, test, and review alongside your web app, in the browser.
      Works with your favorite coding agent and your web framework.
    '';
    license = pkgs.lib.licenses.asl20;
    platforms = ["x86_64-linux"];
    homepage = "https://tidewave.ai/";
    downloadPage = "https://github.com/tidewave-ai/tidewave_app/releases";

    inherit (pkgs) fetchurl appimageTools stdenv buildFHSEnv;
    inherit (lib) optionalAttrs;

    tidewave-app = let
      pname = "tidewave-app";
      src = fetchurl {
        url = "https://github.com/tidewave-ai/tidewave_app/releases/download/${version}/tidewave-app-amd64.AppImage";
        hash = "sha256-DOwN9MUJGKWqyxIyFdTN0TINOfm3xpt443MI9BytRNY=";
      };
      # Extract the AppImage contents so we can grab icons/desktop files
      appimageContents = appimageTools.extract {inherit pname version src;};
    in
      appimageTools.wrapType2 {
        inherit pname version src;

        extraInstallCommands = ''
          install -m 444 -D "${appimageContents}/Tidewave IDE.desktop" \
            $out/share/applications/${pname}.desktop

          cp -r ${appimageContents}/usr/share/icons $out/share/

          substituteInPlace $out/share/applications/${pname}.desktop \
            --replace 'Exec=AppRun' 'Exec=${pname}'
        '';

        meta = {
          inherit longDescription license platforms homepage downloadPage;
          description = "Tidewave Desktop app";
        };
      };

    tidewave-cli-unwrapped = stdenv.mkDerivation rec {
      pname = "tidewave-cli";
      inherit version;

      src = fetchurl {
        url = "https://github.com/tidewave-ai/tidewave_app/releases/download/${version}/tidewave-cli-x86_64-unknown-linux-gnu";
        hash = "sha256-XoXW4b0dLHQcQWToQU9FoZr84U88ymsDn8UwYMeUMR4=";
      };

      dontUnpack = true; # it's a single binary, no archive to unpack
      dontConfigure = true;
      dontBuild = true;

      installPhase = ''
        runHook preInstall
        install -m755 -D $src $out/bin/${pname}
        runHook postInstall
      '';
    };

    tidewave-cli = buildFHSEnv {
      inherit (tidewave-cli-unwrapped) pname version meta;

      runScript = "tidewave-cli";

      targetPkgs = pkgs: [
        tidewave-cli-unwrapped
      ];
    };
  in {
    packages = optionalAttrs (system == "x86_64-linux") {
      inherit tidewave-app tidewave-cli;
    };
  };

  my.aspects.development = {
    features = [
      ["nixos" "Tidewave agent"]
    ];

    homeNixos = {system, ...}: {
      home.packages = with config.flake.packages.${system}; [
        tidewave-app
        tidewave-cli
      ];
    };
  };
}

aspects/development/tts.nix

{
  my.aspects.development = {
    features = [
      ["common" "Linux TTS fallback"]
    ];

    home = {pkgs, ...}: {
      home.packages = with pkgs; [
        espeak-ng
      ];

      home.shellAliases.say = "espeak-ng";
    };
  };
}

aspects/development/zed.nix

{
  my.aspects.development = {
    features = [
      ["common" "Zed editor"]
    ];

    home.programs.zed-editor = {
      enable = true;

      mutableUserDebug = true;
      mutableUserKeymaps = true;
      mutableUserSettings = true;
      mutableUserTasks = true;
    };
  };
}

aspects/gaming.nix

{
  my.aspects.gaming = {
    description = "Gaming-related tools and configurations";
    features = [
      ["nixos" "Steam, Gamescope, and Gamemode"]
      ["nixos" "Lutris, Mangohud, Heroic"]
      ["nixos" "Mudlet"]
    ];

    nixos = {
      config,
      username,
      ...
    }: {
      nixpkgs.overlays = [
        (final: prev: {
          gamescope = prev.gamescope.overrideAttrs (old: {
            patches =
              (old.patches or [])
              ++ [
                # https://github.com/ValveSoftware/gamescope/pull/1908
                (prev.fetchpatch {
                  url = "https://github.com/ValveSoftware/gamescope/commit/fa900b0694ffc8b835b91ef47a96ed90ac94823b.diff";
                  hash = "sha256-eIHhgonP6YtSqvZx2B98PT1Ej4/o0pdU+4ubdiBgBM4=";
                })
              ];
          });
          openldap = prev.openldap.overrideAttrs (_: {
            # Lutris build fails
            # https://github.com/NixOS/nixpkgs/issues/513245
            doCheck = !prev.stdenv.hostPlatform.isi686;
          });
        })
      ];

      programs.gamescope = {
        enable = true;
      };

      programs.steam = {
        enable = true;
        gamescopeSession = {
          enable = true;
        };

        # remotePlay.openFirewall = true;
        # dedicatedServer.openFirewall = true;
        # localNetworkGameTransfers.openFirewall = true;
      };

      home-manager.users.${username} = {
        programs.lutris = {
          enable = true;
          steamPackage = config.programs.steam.package;
        };
      };

      programs.gamemode.enable = true;

      security.pam.loginLimits = [
        # https://github.com/lutris/docs/blob/master/HowToEsync.md
        # this is required by some games
        { domain = username; type = "hard"; item = "nofile"; value = "524288"; }
      ];
    };

    homeNixos = {pkgs, ...}: {
      programs.mangohud.enable = true;

      home.packages = with pkgs; [
        heroic
        mudlet
      ];
    };
  };
}

aspects/gpg.nix

{
  my.aspects.gpg = {
    description = "GPG configuration and shell helpers";

    features = [
      ["common" "GPG setup and Nushell helper functions"]
      ["nixos" "gpg-agent with SSH support and Bash/Nushell integration"]
    ];

    home = {
      programs.gpg = {
        enable = true;
      };

      programs.nushell.extraConfig =
        # nu
        ''
          # Exports secret keys to a file without converting their binary representation.
          #
          # Expects a writable output path and access to the secret keys.
          def ,gpg-export-secrets [file: path] {
            gpg --export-secret-keys out> $file
          }

          # Imports keys from the supplied file.
          #
          # Expects a readable GPG key file.
          def ,gpg-import [file: path] {
            gpg --import $file
          }

          # Exports armored public keys matching the supplied email.
          def ,gpg-export-public [email: string] {
            gpg --export -a $email
          }
        '';
    };

    homeNixos = {
      services.gpg-agent = {
        enable = true;
        enableSshSupport = true;
      };
    };
  };
}

aspects/music-making.nix

{inputs, ...}: {
  my.aspects.music-making = {
    description = "Enables music making on NixOS";
    dependsOn = ["base"];
    features = [
      ["nixos" "musnix real-time audio permissions and system tuning"]
      ["nixos" "Renoise tracker-based DAW (nixpkgs demo for now)"]
    ];

    nixos = {
      lib,
      username,
      ...
    }: {
      imports = [inputs.musnix.nixosModules.musnix];

      # some trick LLM did to avoid conflicts with nixos-cli
      # try to remove this from time to time
      options.musnix.kernel.packages = lib.mkOption {
        defaultText = lib.literalExpression "pkgs.linuxPackages_latest";
      };

      # I'm not sure if this is minimally need config.
      # It does not work with Reniose + ALSA, but works for Renoise + JACK.
      # It took hours to find combo that work =( Why it so complex?
      config = {
        users.users.${username}.extraGroups = ["audio" "pipewire" "rtkit"];

        musnix = {
          enable = true;
          ffado.enable = true;
          soundcardPciId = "c1:00.6";
          rtcqs.enable = true;
        };

        services.pipewire.jack.enable = true;
      };
    };

    homeNixos = {pkgs, ...}: {
      home.packages = [pkgs.renoise];
    };
  };
}

aspects/noctalia-5-desktop/a_meta.nix

{
  my.aspects.noctalia-5-desktop = {
    description = "Niri and Noctalia v5 desktop environment with its greeter";
    dependsOn = ["base"];
  };
}

aspects/noctalia-5-desktop/cursor.nix

let
  name = "phinger-cursors-light";
  size = 24;
in {
  my.aspects.noctalia-5-desktop = {
    features = [
      ["common" "Phinger cursors for Niri and applications"]
      ["nixos" "Matching Phinger cursors on the login screen"]
    ];

    home = {
      config,
      pkgs,
      ...
    }: {
      home.pointerCursor = {
        enable = true;
        package = pkgs.phinger-cursors;
        inherit name size;
        gtk.enable = true;
      };

      gtk.enable = true;

      # Niri draws compositor-owned cursors independently of application settings.
      home.file.".config/niri/cursor.kdl".text =
        # kdl
        ''
          cursor {
              xcursor-theme "${config.home.pointerCursor.name}"
              xcursor-size ${toString config.home.pointerCursor.size}
          }
        '';
    };

    nixos = {pkgs, ...}: {
      # The greeter runs as a separate user and needs its own theme lookup path.
      services.displayManager.noctalia-greeter = {
        cursorTheme = {
          package = pkgs.phinger-cursors;
          inherit name;
        };

        settings.cursor.size = size;
      };
    };
  };
}

aspects/noctalia-5-desktop/greeter.nix

{
  my.aspects.noctalia-5-desktop = {
    features = [
      ["nixos" "Noctalia Greeter"]
    ];

    nixos = {
      services.displayManager.noctalia-greeter = {
        enable = true;

        settings = {
          session.default = "Niri";
          keyboard = {
            layout = "us,ru";
            options = "grp:win_space_toggle";
          };
        };
      };
    };
  };
}

aspects/noctalia-5-desktop/niri.nix

{
  inputs,
  config,
  ...
}: let
  inherit (config.my.helpers) mkDirectSymlink;
in {
  my.aspects.noctalia-5-desktop = {
    features = [
      ["nixos" "Niri WM"]
      ["ubuntu" "Integration with Ubuntu-installed Niri"]
    ];

    nixos = {
      pkgs,
      system,
      ...
    }: {
      programs.niri.enable = true;
      environment.sessionVariables.NIXOS_OZONE_WL = "1";
      environment.sessionVariables.QT_QPA_PLATFORMTHEME = "qt6ct";

      environment.systemPackages = with pkgs; [
        # Niri dependencies
        xwayland-satellite

        # better behavior for floating windows
        inputs.niri-float-sticky.packages.${system}.default

        # Required by Neovim to work with system clipboard
        wl-clipboard
      ];
    };

    # NOTE: on Ubuntu I install Niri in Ubuntu way:
    #
    # https://pacstall.dev/packages/niri/
    # with only `policykit-1-gnome` optional dependency
    homeUbuntu = {
      pkgs,
      system,
      ...
    }: {
      home.sessionVariables = {
        NIXOS_OZONE_WL = "1";
        QT_QPA_PLATFORMTHEME = "qt6ct";
      };

      home.packages = with pkgs; [
        xwayland-satellite
        inputs.niri-float-sticky.packages.${system}.default
        wl-clipboard
      ];
    };

    home = {config, ...}: {
      home.file = {
        # config.kdl is directly symlinked for fast iteration, but it `include`s
        # host-local.kdl, which each host generates from Nix (hosts/<host>/niri.nix).
        ".config/niri/config.kdl".source = mkDirectSymlink config ./niri.kdl;
        ".face".source = mkDirectSymlink config ./avatar.png;
      };
    };

    homeNixos = {pkgs, ...}: {
      services.gpg-agent.pinentry.package = pkgs.pinentry-qt;
    };
  };
}

aspects/noctalia-5-desktop/noctalia.nix

{inputs, ...}: {
  my.aspects.noctalia-5-desktop = {
    features = [
      ["common" "Noctalia v5 shell"]
      ["common" "AI plan usage CLI and TUI for Noctalia plugins"]
      ["ubuntu" "Native PAM authentication for screen unlocking"]
    ];

    nixos = {
      # Noctalia exposes these integrations through external system services.
      networking.networkmanager.enable = true;
      hardware.bluetooth.enable = true;
      services.power-profiles-daemon.enable = true;
      services.upower.enable = true;
    };

    homeUbuntu = {
      config,
      pkgs,
      ...
    }: {
      imports = [inputs.pam-shim.homeModules.default];
      pamShim.enable = true;

      # Nix's libpam cannot authenticate against Ubuntu's native PAM stack.
      programs.noctalia.package = config.lib.pamShim.replacePam pkgs.noctalia;
    };

    home = {
      pkgs,
      system,
      ...
    }: {
      programs.noctalia = {
        enable = true;

        # The compositor owns startup so Noctalia is in the same session as Niri.
        systemd.enable = false;

        settings = {
          audio.enable_overdrive = true;
          backdrop.enabled = true;

          bar = {
            order = ["main"];
            main = {
              start = ["launcher" "theme_mode" "clock" "cpu" "temp" "ram" "privacy"];
              center = ["active_window" "workspaces"];
              end = [
                "tray"
                "bar_2"
                "widget"
                "badge"
                "keyboard_layout"
                "notifications"
                "clipboard"
                "network"
                "bluetooth"
                "volume"
                "caffeine"
                "battery"
                "nix-monitor"
                "bar"
                "control-center"
                "session"
              ];
              margin_ends = 0;
              radius = 8;
              radius_top_left = 0;
              radius_top_right = 0;
              widget_spacing = 8;
            };
          };

          keybinds = {
            down = ["Down" "Ctrl+n"];
            up = ["Up" "Ctrl+p"];
          };

          location.auto_locate = true;
          nightlight.enabled = true;

          plugin_settings = {
            # RSS feeds are managed from the plugin's panel (`+` button) since v1.2,
            # the old feed_urls setting no longer exists.
            "thepunkoff/pomodoro".enable-work-timer-sound = true;
          };

          plugins.enabled = [
            "kenn/keybind-cheatsheet"
            "avivbintangaringga/nix-monitor"
            "thepunkoff/pomodoro"
            "nilsonlinux/rss-notifier"
            "noctalia/wallhaven"
            "noctalia/wallpaper_depth"
            "raycursive/niri-displays"
            "felipeartur/ai-usagebar"
          ];

          shell = {
            external_ip_enabled = true;
            font_family = "Iosevka Etoile";
            password_style = "random";
            polkit_agent = true;
            screen_time_enabled = true;
            telemetry_enabled = true;

            launcher.layout = "simple";

            panel = {
              open_near_click_control_center = true;
              open_near_click_session = true;
              session_position = "center";
            };

            screenshot = {
              annotate = true;
              directory = "~/Pictures/Screenshots";
            };
          };

          theme = {
            builtin = "Ayu";
            community_palette = "Oxocarbon";
            mode = "dark";
            source = "builtin";
            wallpaper_scheme = "m3-content";

            templates = {
              builtin_ids = ["btop" "gtk3" "gtk4" "kitty" "niri" "qt"];
              community_ids = ["zen-browser" "bat" "yazi"];
            };
          };

          widget = {
            badge.type = "nilsonlinux/rss-notifier:badge";
            bar = {
              show_resolution = false;
              type = "raycursive/niri-displays:bar";
            };
            bar_2.type = "felipeartur/ai-usagebar:bar";
            keyboard_layout.show_glyph = false;
            network.show_label = false;
            nix-monitor = {
              checking_color = "tertiary";
              show_text = false;
              type = "avivbintangaringga/nix-monitor:nix-monitor";
              up_to_date_color = "primary";
              update_available_color = "secondary";
            };
            privacy.hide_inactive = true;
            volume.show_label = false;
            widget.type = "thepunkoff/pomodoro:widget";
          };
        };
      };

      home.shellAliases = {
        ",noctalia-wallpaper-depth" = "noctalia msg panel-toggle noctalia/wallpaper_depth:manager";
      };

      home.packages = with pkgs; [
        # requrements of https://github.com/akitaonrails/ai-usagebar
        # ai-usagebar cannot use Codex API directly and needs CLI tool installed
        codex
        inputs.ai-usagebar.packages.${system}.default

        # requrements of https://github.com/noctalia-dev/official-plugins/tree/main/wallpaper_depth
        # NixOS system should have python3 and some libs globally available
        # (but I haven't tested if wrapping Noctalia with them is enough or not)
        (python314.withPackages (python-pkgs:
          with python-pkgs; [
            numpy
            onnxruntime
            pillow
          ]))

        playerctl
        brightnessctl
        imagemagick
        cliphist
        wlsunset
        nwg-look
        adw-gtk3
        qt6Packages.qt6ct
      ];
    };
  };
}

aspects/reverse-proxy.nix

{config, ...}: {
  my.aspects.reverse-proxy = {
    description = "Local reverse proxy";

    features = [
      ["nixos" "Caddy reverse proxy with local certificates"]
    ];

    nixos = {pkgs, ...}: {
      services.caddy = {
        enable = true;
        globalConfig = ''
          local_certs
        '';
      };

      networking.firewall.allowedTCPPorts = [80 443];

      # needed for certutils; caddy uses it for certs manipulation
      environment.systemPackages = with pkgs; [nss];
    };
  };
}

aspects/server-management.nix

{
  my.aspects.server-management = let
    serverIP = "37.205.14.157";
  in {
    description = "Configs and helpers to manage my personal VPS";
    features = [
      ["nixos" "Personal server alias"]
      ["common" "Personal server config mount (rclone)"]
      ["common" "Nushell helper for SSH port forwarding"]
    ];

    nixos = {
      networking.hosts = {
        ${serverIP} = ["server"];
      };
    };

    home = {username, ...}: {
      home.shellAliases = {
        ",server-ssh" = "ssh root@server";
        ",server-update" = "ssh root@server 'cd /etc/nixos && nixos-rebuild --flake .#vps switch'";
      };

      programs.nushell.extraConfig =
        # nu
        ''
          # Forwards a local port to a server-local port over SSH.
          #
          # Expects valid TCP port numbers and SSH access to root@server.
          def ,server-port [local_port: int, remote_port: int] {
            ssh -N -L $"($local_port):localhost:($remote_port)" root@server
          }
        '';

      programs.rclone = {
        enable = true;

        remotes.server = {
          config = {
            type = "sftp";
            host = "server";
            user = "root";
            key_file = "~/.ssh/id_ed25519";
            known_hosts_file = "~/.ssh/known_hosts";
            shell_type = "unix";
          };

          # creates systemd service that responsible for mounting
          mounts = {
            "/etc/nixos" = {
              enable = true;
              mountPoint = "/home/${username}/Projects/server";
            };
          };
        };
      };
    };
  };
}

aspects/shell/a_meta.nix

{config, ...}: {
  my.aspects.shell = {
    description = "Bash login environment, Nushell sessions, and CLI quality-of-life tools.";
    dependsOn = ["base"];
  };
}

aspects/shell/bash.nix

{
  my.aspects.shell = {
    features = [
      ["nixos" "Bash as the primary user's login shell"]
      ["common" "Interactive Bash sessions initialize the environment and start Nushell"]
    ];

    nixos = {
      pkgs,
      username,
      ...
    }: {
      users.users.${username}.shell = pkgs.bashInteractive;
    };

    home = {
      config,
      lib,
      ...
    }: {
      programs.bash = {
        enable = true;
        # Nushell must inherit the environment after all Bash integrations initialize.
        initExtra = lib.mkOrder 3000 ''
          if ! [ "$TERM" = "dumb" ] && [ -z "$BASH_EXECUTION_STRING" ]; then
            exec ${lib.getExe config.programs.nushell.package}
          fi
        '';
      };
    };

    homeUbuntu = {
      # Bash login sessions need system-manager's paths to find system-level applications.
      programs.bash.profileExtra = ''
        source /etc/profile.d/system-manager-path.sh
      '';
    };
  };
}

aspects/shell/functions.nix

{config, ...}: let
  inherit (config.my.helpers) mkDirectSymlink;
in {
  my.aspects.shell = {
    features = [
      ["common" "Nushell helpers for long-running commands and PDF compression"]
    ];

    home = {
      pkgs,
      config,
      ...
    }: {
      home.packages = [pkgs.espeak-ng];

      home.file.".config/nushell/functions.nu".source = mkDirectSymlink config ./functions.nu;

      programs.nushell.extraConfig =
        # nu
        ''
          source "functions.nu"
        '';
    };
  };
}

aspects/shell/modern-tools.nix

{
  my.aspects.shell = {
    features = [
      ["common" "Zoxide directory tracking with native Nushell fuzzy picking via zi"]
      ["common" "Local Atuin fuzzy history search on Ctrl+R in Nushell"]
      ["common" "Btop and htop (modern top replacements)"]
      ["common" "Bat (modern cat with syntax highlighting)"]
      ["common" "Batman (man pages with bat)"]
      ["common" "Yazi terminal file manager with Bash and Nushell integration"]
    ];

    home = {pkgs, ...}: {
      programs.zoxide.enable = true;

      programs.atuin = {
        enable = true;
        flags = ["--disable-up-arrow"];
        settings = {
          auto_sync = false;
          search_mode = "fuzzy";
          enter_accept = false;
        };
      };

      # Better top
      programs.btop.enable = true;
      programs.htop.enable = true;

      # Better cat & man
      programs.bat.enable = true;

      home.packages = with pkgs.bat-extras; [
        batman
      ];

      # Let Batman generate its own pager settings for Bash and its child processes.
      programs.bash.bashrcExtra = ''
        eval "$(batman --export-env)"
      '';

      # File manager
      programs.yazi = {
        enable = true;
        shellWrapperName = "y";
        package = pkgs.yazi.override {
          # support for rar files
          _7zz = pkgs._7zz-rar;
        };
      };
    };
  };
}

aspects/shell/nushell.nix

{
  my.aspects.shell = {
    features = [
      ["common" "Nushell with Home Manager-generated configuration"]
      ["common" "Nushell MCP server"]
      ["common" "Carapace completions for Bash and Nushell"]
      ["common" "Starship prompt for Nushell"]
    ];

    home = {
      config,
      lib,
      ...
    }: {
      programs.nushell = {
        enable = true;
        settings = {
          edit_mode = "vi";
          show_banner = false;
          table.mode = "frameless";
        };
        shellAliases = {
          la = "ls -la";
          # Carapace caches discovered bridge completers for 24h, so newly
          # installed completions stay invisible until the cache is dropped.
          ",carapace-reset-cache" = "rm -rf ~/.cache/carapace";
        };
      };

      programs.mcp.servers.nushell = {
        enabled = true;
        command = lib.getExe config.programs.nushell.package;
        args = ["--mcp"];
      };

      # I want Bash to be a simple wrapper for starting Nushell with right context
      # and minimal fallback shell, so I skip integrating HM-managed software.
      home.shell.enableBashIntegration = false;

      # Universal autocompletion
      programs.carapace.enable = true;
      home.sessionVariables = {
        CARAPACE_BRIDGES = "zsh,fish,bash,inshellisense";
      };

      programs.starship = {
        enable = true;
        settings = {
          add_newline = false;
        };
      };
    };
  };
}

aspects/terminal.nix

{config, ...}: let
  inherit (config.my.helpers) mkDirectSymlink;
in {
  my.aspects.terminal = {
    description = "Terminal emulator configuration";

    features = [
      ["common" "Kitty terminal emulator with directly symlinked config"]
    ];

    home = {
      pkgs,
      config,
      ...
    }: {
      home.packages = with pkgs; [
        kitty
      ];

      # To simplify tinkering with terminal configuration, we symlink the
      # configuration files directly to the files in the dotfiles
      # directory of this repository. (Instead of making them part of the
      # Nix store.)
      home.file.".config/kitty/kitty.conf".source = mkDirectSymlink config ./terminal/kitty.conf;
    };
  };
}

hosts/framework-13-amd-ai-300.nix

# Framework 13 laptop (AMD AI-300 series)
{
  my.hosts.framework-13-amd-ai-300 = {
    hostname = "framework13";
    username = "ffloyd";
    email = "roman@ffloyd.space";
    gpgKey = "A16DC4CD1A040EDE";
    system = "x86_64-linux";

    aspects = [
      "base"
      "shell"
      "terminal"
      "gpg"
      "development"
      "server-management"
      "desktop-apps"
      "noctalia-5-desktop"
      "browser"
      "gaming"
      "music-making"
      "reverse-proxy"
    ];

    nixos = {
      system.stateVersion = "25.05";
    };

    home = {
      home.stateVersion = "24.11";
    };
  };
}

hosts/framework-13-amd-ai-300/bluetooth.nix

{
  my.hosts.framework-13-amd-ai-300 = {
    adjustments = [
      "Enable Bluetooth"
    ];

    nixos = {
      hardware.bluetooth.enable = true;
    };
  };
}

hosts/framework-13-amd-ai-300/bootloader.nix

# Objective: Bootloader, kernel, and disk encryption configuration
{
  my.hosts.framework-13-amd-ai-300 = {
    adjustments = [
      "LUKS disk encryption"
      "systemd-boot bootloader"
    ];

    nixos = {pkgs, lib, ...}: {
      # Decrypt LUKS partitions on boot
      boot.initrd.luks.devices."luks-584448a8-c11d-4f10-828a-31a1267eef0f".device = "/dev/disk/by-uuid/584448a8-c11d-4f10-828a-31a1267eef0f";

      # Use latest kernel
      # Aspects like `music-making` can override it, so we set only default value here.
      boot.kernelPackages = lib.mkDefault pkgs.linuxPackages_latest;

      # `systemd-boot` works with minimal config and very reliable.
      # But it looks bad on hdpi. Pressing `r` once sytemd-boot is loaded
      # will switch to consolemod with lower resolution, so it's not a problem
      # considering that we hide boot menu by default.
      boot.loader = {
        systemd-boot.enable = true;
        efi.canTouchEfiVariables = true;

        # show menu it only if user spams some button
        # this trick will preserve Framework logo on boot.
        timeout = 0;
      };
    };
  };
}

hosts/framework-13-amd-ai-300/community-hardware.nix

# Apply community-maintained hardware tweaks for Framework 13
{inputs, ...}: {
  my.hosts.framework-13-amd-ai-300 = {
    adjustments = [
      "Hardware tweaks made by community (NixOS Hardware project)"
      "Fix shitty audio hardware with software-level adjustments (from NixOS Hardware project)"
    ];

    nixos = {
      imports = [inputs.nixos-hardware.nixosModules.framework-amd-ai-300-series];

      hardware.framework.laptop13.audioEnhancement = {
        # enable = true;
        # disabled to avoid problems with music-making software
        enable = false;

        # use
        # $ pw-dump | grep "node.name.*alsa_output"
        # to find the new correct device name if it stopped working after some update
        # rawDeviceName = "alsa_output.pci-0000_c1_00.6.HiFi__Speaker__sink";

        # the correct one when UCM is disabled
        rawDeviceName = "alsa_output.pci-0000_c1_00.6.analog-stereo";
      };
    };
  };
}

hosts/framework-13-amd-ai-300/firmware.nix

#  Enable firmware updates for Framework 13
{
  my.hosts.framework-13-amd-ai-300 = {
    adjustments = [
      "Firmware updates"
    ];

    nixos = {username, ...}: {
      hardware.enableAllFirmware = true;
      services.fwupd.enable = true;
      home-manager.users.${username} = {
        home.shellAliases.os-firmware-update = "fwupdmgr update";

        programs.nushell.extraConfig =
          # nu
          ''
            def os-firmware-check-updates [] {
              fwupdmgr refresh
              fwupdmgr get-updates
            }
          '';
      };
    };
  };
}

hosts/framework-13-amd-ai-300/framework-kmod.nix

{
  my.hosts.framework-13-amd-ai-300 = {
    adjustments = [
      "Backport Framework kernel module signing fix (nixpkgs#575818)"
    ];

    nixos = {pkgs, ...}: {
      # Manual installation bypasses signing and leaves the module certificate missing.
      # Remove once the nixpkgs pin includes the fix from:
      # https://github.com/NixOS/nixpkgs/pull/575818
      # Related reports:
      # https://github.com/NixOS/nixpkgs/issues/575192
      # https://github.com/NixOS/nixos-hardware/issues/2076
      boot.kernelPackages = pkgs.linuxPackages_latest.extend (_: previous: {
        framework-laptop-kmod = previous.framework-laptop-kmod.overrideAttrs (old: {
          makeFlags =
            old.makeFlags
            ++ [
              "INSTALL_MOD_PATH=${builtins.placeholder "out"}"
              "INSTALL_MOD_DIR=extra"
              "DEPMOD=true"
            ];

          installPhase = null;
          installTargets = ["modules_install"];
        });
      });
    };
  };
}

hosts/framework-13-amd-ai-300/keyboard.nix

# Adjust internal keyboard behavior
{
  my.hosts.framework-13-amd-ai-300 = {
    adjustments = [
      "Keyboard remapping"
    ];

    nixos = {
      services.keyd = {
        enable = true;
        keyboards.default = {
          # they may change after some updates
          # use `nix-shell -p keyd` and then
          # `sudo keyd monitor` to find a correct one if it stopped working
          ids = [
            "0001:0001:70533846" # internal keyboard (first detected ID)
            "0001:0001:09b4e68d" # current ID as of 2025-10-09
          ];
          settings = {
            main = {
              # left alt <-> left cmd
              # this is also done physically on the keyboard
              leftalt = "layer(meta)";
              leftmeta = "layer(alt)";

              # capslock -> (held) ctrl, (tap) ESC
              capslock = "overloadt2(control, esc, 150)";
            };
          };
        };
      };
    };
  };
}

hosts/framework-13-amd-ai-300/microphone.nix

# Fix not working internal microphone
# https://github.com/NixOS/nixos-hardware/issues/1603
# https://community.frame.work/t/microphone-not-working-after-nixos-update/74915
{
  my.hosts.framework-13-amd-ai-300 = {
    adjustments = [
      "Internal microphone fix"
    ];

    nixos = {
      services.pipewire.wireplumber.extraConfig.no-ucm = {
        "monitor.alsa.properties" = {
          "alsa.use-ucm" = false;
        };
      };
    };
  };
}

hosts/framework-13-amd-ai-300/niri.nix

# Niri host-local settings for the Framework 13 laptop
{
  my.hosts.framework-13-amd-ai-300 = {
    adjustments = [
      "Niri outputs"
    ];

    home = {
      home.file.".config/niri/host-local.kdl".text =
        # kdl
        ''
          // Generated by Nix.
          // Included by ~/.config/niri/config.kdl, see aspects/noctalia-5-desktop/niri.kdl.
          // Source: hosts/framework-13-amd-ai-300/niri.nix

          output "eDP-1" {
            position x=0 y=0
            scale 2
          }

          output "Advanced Micro Peripherals Ltd ES07D03 EVE222500661" {
            scale 1.5
          }
        '';
    };
  };
}

hosts/framework-13-amd-ai-300/noctalia.nix

{
  my.hosts.framework-13-amd-ai-300 = {
    adjustments = [
      "Noctalia greeter synchronization"
      "Noctalia Nix update command"
      "Noctalia wallpaper depth"
    ];

    home.programs.noctalia.settings = {
      shell.greeter_sync.auto_sync = true;

      plugin_settings = {
        "avivbintangaringga/nix-monitor".update_command = "cd ~/nix && nix flake update && nixos apply --local-root";
      };
    };
  };
}

hosts/framework-13-amd-ai-300/packages.nix

# Hardware-specific software packages
{
  my.hosts.framework-13-amd-ai-300 = {
    adjustments = [
      "Hardware-specific packages"
    ];

    nixos = {
      pkgs,
      username,
      ...
    }: {
      home-manager.users.${username}.home.packages = with pkgs; [
        # AMD GPU monitoring tool
        nvtopPackages.amd

        # Wireless network monitoring tool
        wavemon
      ];
    };
  };
}

hosts/framework-13-amd-ai-300/plymouth.nix

# Beautify boot process with Plymouth
{
  my.hosts.framework-13-amd-ai-300 = {
    adjustments = [
      "Plymouth boot splash"
    ];

    nixos = {pkgs, ...}: {
      # Silent boot: so Framework logo will be replaced with Plymouth seamless
      boot.consoleLogLevel = 0;
      boot.kernelParams = [
        # this two makes initrd really quiet
        "quiet"
        "udev.log_level=3"
        # required by Plymouth
        "splash"
        # allow Plymouth to render before amdgpu driver is loaded
        # by reusing EFI's simpledrm
        "plymouth.use-simpledrm"
        # this (maybe) reduces flickering on boot
        "amdgpu.seamless=1"
      ];

      # Plymouth: make loading screen look nice
      boot.plymouth = {
        enable = true;
        # other themes I tried had issues with external monitor:
        # Plymouth was rendered on it with bad placement
        theme = "nixos-bgrt";
        themePackages = [
          pkgs.nixos-bgrt-plymouth
        ];
      };
    };
  };
}

hosts/framework-13-amd-ai-300/power.nix

# Proper power management for Framework 13 laptop
{
  my.hosts.framework-13-amd-ai-300 = {
    adjustments = [
      "Power management"
    ];

    nixos = {
      services.upower.enable = true;
      services.power-profiles-daemon.enable = true;
    };
  };
}

hosts/ubuntu-work.nix

# Work laptop (Ubuntu + system-manager)
{
  my.hosts.ubuntu-work = {
    hostname = "T14";
    username = "roman-kolesnev";
    email = "roman.kolesnev@driftrock.com";
    gpgKey = "39F9E6C95CA226A5";
    system = "x86_64-linux";
    type = "ubuntu";

    aspects = ["base" "shell" "terminal" "development" "gpg" "desktop-apps" "noctalia-5-desktop" "browser"];

    home = {
      home.stateVersion = "24.11";
    };
  };
}

hosts/ubuntu-work/ai.nix

# AI tools that I use at work
#
# In a working environment I do not always have freedom
# to use tools I really prefer. Escpecially in AI context
# (due to compliance etc.) So I keep such configs separately here.
{
  config,
  inputs,
  ...
}: let
  inherit (config.my.helpers) mkDirectSymlink;
in {
  my.hosts.ubuntu-work = {
    adjustments = [
      "Claude Code setup"
    ];

    home = {
      lib,
      system,
      config,
      ...
    }: let
      skillsDir = ./../../aspects/development/ai-agents/skills;

      # Linked one by one, not as a whole directory, because ~/.claude/skills also
      # holds work-only skills and Claude Code's own synced skills, which must stay out of this repo.
      skillLinks = lib.pipe skillsDir [
        builtins.readDir
        (lib.filterAttrs (_: type: type == "directory"))
        (lib.mapAttrs' (name: _: {
          name = ".claude/skills/${name}";
          value.source = mkDirectSymlink config (skillsDir + "/${name}");
        }))
      ];
    in {
      home.packages = with inputs.llm-agents.packages.${system}; [
        claude-code
      ];

      home.file =
        {
          ".claude/CLAUDE.md".source = mkDirectSymlink config ./../../aspects/development/ai-shared/coding-rules.md;
        }
        // skillLinks;
    };
  };
}

hosts/ubuntu-work/neovim.nix

# Work-specific Neovim look
{
  my.hosts.ubuntu-work = {
    adjustments = ["Rose Pine colorscheme in Neovim"];

    home = {
      home.sessionVariables.NVIM_ROSE_PINE = "1";
    };
  };
}

hosts/ubuntu-work/niri.nix

# Niri host-local settings for the T14 work laptop
{
  my.hosts.ubuntu-work = {
    adjustments = [
      "Niri outputs"
    ];

    home = {
      home.file.".config/niri/host-local.kdl".text =
        # kdl
        ''
          // Generated by Nix.
          // Included by ~/.config/niri/config.kdl, see aspects/noctalia-5-desktop/niri.kdl.
          // Source: hosts/ubuntu-work/niri.nix

          output "AU Optronics B140UAN02.7  Unknown" {
            position x=0 y=0
            scale 1.25
          }

          output "DP-4" {
            scale 2
          }
        '';
    };
  };
}

hosts/ubuntu-work/productivity.nix

# Work productivity tools
{
  my.hosts.ubuntu-work = {
    adjustments = [
      "Productivity tools (Slack, etc.)"
      "Work-related shell helpers"
      "Work development-environment CLI with completions"
      "Nushell autoloads every ~/dev/helpers/*.nu"
    ];

    home = {
      config,
      pkgs,
      ...
    }: {
      home.packages = with pkgs; [
        slack
        television

        # for out-of-docker LSP
        beam28Packages.elixir_1_20
        beam28Packages.expert
      ];

      programs.bash.bashrcExtra = ''
        source ${config.home.homeDirectory}/.env
      '';

      home.sessionPath = [
        "${config.home.homeDirectory}/.local/bin"
        # Nu defs from ~/dev/helpers/*.nu exist only inside interactive Nushell, while
        # non-Nu callers (e.g. Neovim's plugins) need real executables on PATH,
        # so bin/ holds thin Nu wrappers around the defs they use.
        "${config.home.homeDirectory}/dev/helpers/bin"
      ];

      # Carapace's bash bridge only discovers completions via bash-completion's
      # lazy-loading dir (file named after the command), not via .bashrc sourcing.
      xdg.dataFile."bash-completion/completions/driftrock".source =
        config.lib.file.mkOutOfStoreSymlink
        "${config.home.homeDirectory}/dev/driftrock/dev-environment/lib/driftrock-completion";

      # Nushell's `source` needs a parse-time constant path, so it can't glob;
      # the user-autoload dir is the only way to pick up helpers added later.
      xdg.configFile."nushell/autoload".source =
        config.lib.file.mkOutOfStoreSymlink
        "${config.home.homeDirectory}/dev/helpers";
    };
  };
}