{
  description = "Mora Unie Youer's NixOS configuration";

  # This section is hugely uses "input reusing" so that there will be no copies
  # of the same repository on flake update
  # NOTE: unless it is needed :wink:
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    nixpkgs-pinned.url = "github:NixOS/nixpkgs/4fb937aabc3321e28d8bfe444d781afad09e0951";

    nix-filter.url = "github:numtide/nix-filter";

    flake-compat = {
      url = "github:edolstra/flake-compat";
      flake = false;
    };

    flake-utils.url = "github:numtide/flake-utils";

    flake-parts = {
      url = "github:hercules-ci/flake-parts";
      inputs.nixpkgs-lib.follows = "nixpkgs";
    };

    rust-overlay = {
      url = "github:oxalica/rust-overlay";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    nurpkgs = {
      url = "github:nix-community/NUR";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.flake-parts.follows = "flake-parts";
    };

    nyxpkgs = {
      url = "github:chaotic-cx/nyx";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.home-manager.follows = "home-manager";
    };

    # Secure Boot bootloader
    lanzaboote = {
      url = "github:nix-community/lanzaboote";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.flake-compat.follows = "flake-compat";
      inputs.flake-parts.follows = "flake-parts";
      inputs.rust-overlay.follows = "rust-overlay";
    };

    # Setup NixOS sound subsystem better
    musnix = {
      url = "github:musnix/musnix";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    # Applications
    astal = {
      url = "github:Aylur/astal";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    aylurs-gtk-shell = {
      url = "github:Aylur/ags";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.astal.follows = "astal";
    };

    fjordlauncher = {
      url = "github:unmojang/FjordLauncher";
      # NOTE: re-following inputs breaks Cachix
      #inputs.nixpkgs.follows = "nixpkgs";
      #inputs.nix-filter.follows = "nix-filter";
      #inputs.flake-compat.follows = "flake-compat";
    };

    niri = {
      # NOTE: using this repo to use cachix binaries
      url = "github:sodiboo/niri-flake";

      # url = "github:YaLTeR/niri";
      # inputs.nixpkgs.follows = "nixpkgs";
      # inputs.nix-filter.follows = "nix-filter";
      # inputs.rust-overlay.follows = ""; # NOTE: for end user is not requried
    };

    wezterm = {
      url = "github:wezterm/wezterm?dir=nix";
      # NOTE: re-following inputs breaks Cachix
      #inputs.nixpkgs.follows = "nixpkgs";
      #inputs.flake-utils.follows = "flake-utils";
      #inputs.rust-overlay.follows = "rust-overlay";
    };

    # NOTE: re-following inputs breaks Cachix
    neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";

    neovim-configuration = {
      url = "git+https://git.140041.xyz/neovim-configuration";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.neovim-nightly-overlay.follows = "neovim-nightly-overlay";
    };
  };

  nixConfig = {
    extra-substituters = [
      # NOTE: Some of the cachix repositories do not work for some reason :^(
      "https://nix-community.cachix.org"
      "https://chaotic-nyx.cachix.org"
      "https://unmojang.cachix.org"
      "https://wezterm.cachix.org"
      "https://niri.cachix.org"
      "https://neovim-nightly.cachix.org"
    ];

    extra-trusted-public-keys = [
      # NOTE: Some of the cachix repositories do not work for some reason :^(
      "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
      "chaotic-nyx.cachix.org-1:HfnXSw4pj95iI/n17rIDy40agHj12WfF+Gqk6SonIT8="
      "unmojang.cachix.org-1:OfHnbBNduZ6Smx9oNbLFbYyvOWSoxb2uPcnXPj4EDQY="
      "wezterm.cachix.org-1:kAbhjYUC9qvblTE+s7S+kl5XM1zVa4skO+E/1IDWdH0="
      "niri.cachix.org-1:Wv0OmO7PsuocRKzfDoJ3mulSl7Z6oezYhGhR+3W2964="
      "neovim-nightly.cachix.org-1:feIoInHRevVEplgdZvQDjhp11kYASYCE2NGY9hNrwxY="
    ];
  };

  outputs = {
    self,

    nixpkgs,
    nurpkgs,
    nyxpkgs,
    home-manager,

    lanzaboote,

    musnix,

    fjordlauncher,
    niri,
    wezterm,

    neovim-configuration,

    ...
  } @ inputs:
    let
      system = "x86_64-linux";
    in {
      nixosConfigurations.sapphire = nixpkgs.lib.nixosSystem rec {
        inherit system;
        specialArgs = { inherit inputs; };

        modules = [
          nurpkgs.modules.nixos.default
          nyxpkgs.nixosModules.default
          home-manager.nixosModules.home-manager

          lanzaboote.nixosModules.lanzaboote

          musnix.nixosModules.default

          {
            nixpkgs.overlays = [
              fjordlauncher.overlays.default
              niri.overlays.niri
            ];
          }

          {
            nix.trustedUsers = [ "root" "mora" ];
          }

          # System Configuration
          ./system-sapphire.nix
          neovim-configuration.nixosModules.default

          # User Configurations
          # mora@sapphire
          ({ pkgs, ... }: {
            users.users.mora = {
              isNormalUser = true;
              extraGroups = [ "audio" "docker" "libvirtd" "lp" "scanner" "video" "wireshark" "wheel" ];
              shell = pkgs.nushell;
            };

            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;
            home-manager.extraSpecialArgs = specialArgs;
            home-manager.users.mora = import ./user-mora.nix;
          })
        ];
      };
    };
}