{
    config,
    pkgs,
    lib,
    hostname,
    env,
    ...

}:

{
    imports = [ ./hardware-configuration.nix ] ++ lib.optional (env ? nixosModule) env.nixosModule;

    nix.settings.experimental-features = [
        "nix-command"
        "flakes"
    ];
    nixpkgs.config.allowUnfree = true;

    environment.systemPackages = with pkgs; [
        chromium

        libsecret
        gnome-keyring
        adwaita-icon-theme
        gtk3

        vim
        git
        xh
        jq
        fzf
        ripgrep

        # perhaps set up lsps through dev shells someday?
        nodejs_latest
        typescript-language-server
        prettierd
        pnpm
        nixd
        nixfmt
        clang
        llvmPackages.bintools
        stylua
        go
    ];

    fonts.packages = with pkgs; [
        noto-fonts
        noto-fonts-cjk-sans
        noto-fonts-color-emoji
        jetbrains-mono
        nerd-fonts.symbols-only
        inter
        nimbus-roman
        monaco
    ];

    fonts.fontconfig = {
        enable = true;
        defaultFonts = {
            monospace = [
                "JetBrains Mono"
                "Symbols Nerd Font"
                "Liberation Mono"
                "Monaco"
            ];
            sansSerif = [
                "Inter"
                "Noto Sans"
            ];
            serif = [ "Nimbus Roman" ];
        };
    };

    services = {
        xserver = {
            enable = true;

            windowManager.i3 = {
                enable = true;
                extraPackages = with pkgs; [
                    rofi
                    i3status
                ];
            };
            displayManager.startx.enable = true;

            xkb = {
                layout = "us";
                variant = "";
                options = "caps:super";
            };

            excludePackages = with pkgs; [ xterm ];
        };
        greetd = {
            enable = true;
            restart = false;
            settings.default_session = {
                command = lib.concatStringsSep " " [
                    "${lib.getExe pkgs.tuigreet}"
                    "--remember"
                    "--asterisks"
                    "--time"
                ];
                user = "greeter";
            };
        };
    };

    programs.chromium = import ./home/chromium.nix;

    programs.fish.enable = true;
    programs.bash.interactiveShellInit = ''
        if [[ $(${pkgs.procps}/bin/ps --no-header --pid=$PPID --format=comm) != "fish" && -z ''${BASH_EXECUTION_STRING} ]] then
        	shopt -q login_shell && LOGIN_OPTION='--login' || LOGIN_OPTION=""
        	exec ${pkgs.fish}/bin/fish $LOGIN_OPTION
        fi
    '';

    # Define a user account. Don't forget to set a password with ‘passwd’.
    users.users.anton = {
        isNormalUser = true;
        description = "anton";
        shell = pkgs.bash;
        extraGroups = [
            "networkmanager"
            "wheel"
        ];
    };

    programs.dconf.enable = true;
    qt = {
        enable = true;
        platformTheme = "gnome";
        style = "adwaita-dark";
    };

    hardware = {
        graphics = {
            enable = true;
            extraPackages = with pkgs.unstable; [
                intel-media-driver
                intel-vaapi-driver
                libvdpau-va-gl
                (pkgs.mesa)
            ];
        };
        bluetooth = {
            enable = true;
            powerOnBoot = true;

            settings.General = {
                Experimental = true;
                FastConnectable = true;
            };
            settings.Policy.AutoEnable = true;
        };
    };

    programs.gnupg.agent = {
        enable = true;
        enableSSHSupport = true;
    };

    services.gnome.gnome-keyring.enable = true;

    boot = {
        loader.systemd-boot = {
            enable = true;
            configurationLimit = 10;
        };
        loader.efi.canTouchEfiVariables = true;

        kernelParams = [ "console=tty1" ];
        kernelPackages = pkgs.unstable.linuxPackages_latest;
    };

    networking = {
        hostName = hostname;

        firewall.enable = false;
        networkmanager.enable = true;
    };

    time.timeZone = "Europe/Stockholm";

    i18n.defaultLocale = "en_US.UTF-8";
    i18n.extraLocaleSettings = {
        LC_ADDRESS = "sv_SE.UTF-8";
        LC_IDENTIFICATION = "sv_SE.UTF-8";
        LC_MEASUREMENT = "sv_SE.UTF-8";
        LC_MONETARY = "sv_SE.UTF-8";
        LC_NAME = "sv_SE.UTF-8";
        LC_NUMERIC = "sv_SE.UTF-8";
        LC_PAPER = "sv_SE.UTF-8";
        LC_TELEPHONE = "sv_SE.UTF-8";
        LC_TIME = "sv_SE.UTF-8";
    };

    # This value determines the NixOS release from which the default
    # settings for stateful data, like file locations and database versions
    # on your system were taken. It‘s perfectly fine and recommended to leave
    # this value at the release version of the first install of this system.
    # Before changing this value read the documentation for this option
    # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
    system.stateVersion = "25.05"; # Did you read the comment?
}
