Broken system from config in configuration.nix

Im not sure what config caused the error since I added multiple lines of config at the same time.

Now all variations of configuration.nix is causing this error now when running sudo nixos-rebuild switch:


building '/nix/store/3nf1dj15xmrkl7dfdiqklpghngv2avl3-unit-systemd-fsck-.service.drv'...
building '/nix/store/1m6av1l315daj7wpf5pfwz2mxxhvzyn1-X-Restart-Triggers.drv'...
building '/nix/store/nrykpbr76mfpgks69qhcg3j6a82xs4ci-etc-nixos-env-preinit.fish.drv'...
building '/nix/store/pmy284bxqfhl8l6nxfl2fbr454haq8sm-etc-profile.drv'...
building '/nix/store/wi8dld88wcc9zli7m4wasyfmlc98zqi6-unit-polkit.service.drv'...
building '/nix/store/rl7v7xd1xz001syh3j1w4w2l4n2ppxrk-unit-dbus.service.drv'...
building '/nix/store/yfdp2hclp8dy097j15wzl673nksgcprf-unit-dbus.service.drv'...
building '/nix/store/h30prplfbfl0mpj8z9046k872imjqncw-user-units.drv'...
building '/nix/store/wnhpspv95vx4lsrk5clmpyfcxgi3q4y1-system-units.drv'...
building '/nix/store/qcgwcixfi1m9q3a7wc1zmqk788zaf7s5-etc-man_db.conf.drv'...
building '/nix/store/gp7qyb2w4zwgs4hhx9m20k8q7ahrahac-etc.drv'...
building '/nix/store/22lv8qck7xms4b0rwspyiyagnv0gjbpv-nixos-system-Z-23.05.3976.32dcb45f66c0.drv'...
stopping the following units: accounts-daemon.service, avahi-daemon.service, avahi-daemon.socket, systemd-modules-load.service
NOT restarting the following changed units: systemd-fsck@dev-disk-by\x2duuid-22E5\x2dB1AF.service
activating the configuration...
setting up /etc...
removing obsolete symlink ‘/etc/profiles/per-user/magnus’...
reloading user units for magnus...
^C

tried to check logs but little is shown. any way to “rebuild” or fix the config? Seems that some config I added broke the whole system.

my config file which seems to break system, after switching to this one, even default nixos config is not working. restart tried ofc:

{ config, pkgs, ... }:
{
  imports = [
    ./hardware-configuration.nix
  ];

  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  networking.hostName = "z";
  networking.networkmanager.enable = true;

  time.timeZone = "Europe/Oslo";

  i18n.defaultLocale = "en_US.UTF-8";
  console = {
  font = "Lat2-Terminus16";
  keyMap = "no";
  };

  nix.settings.experimental-features = [ "nix-command" "flakes" ];



  systemd.user.services.autorandr = {
    description = "autorandr profile loader";
    serviceConfig = {
      Type = "oneshot";
      RemainAfterExit = "yes";
    };
    script = ''
      ${pkgs.autorandr}/bin/autorandr --change --default mobile
    '';
    wantedBy = [ "graphical-session.target" ];
  };

  systemd.user.services.fish-update-completions = {
  description = "Update Fish Shell Completions";
  after = [ "graphical-session.target" ];  # Or other relevant targets or services
  serviceConfig = {
    Type = "oneshot";
    ExecStart = "${pkgs.fish}/bin/fish -c 'fish_update_completions'";
  };
};




# Systemd Service to configure display settings
  systemd.services.display-setup = {
    description = "Configure Display and Reset Dock";
    
    # Specify the paths where required executables are found
    path = [ pkgs.autorandr ];

    # Define when this service should be triggered
    after = [ "graphical.target" ];
    requires = [ "graphical.target" ];
    
    # The script to execute
    script = ''
      autorandr --load home
    '';
    
    # Additional service configurations
    serviceConfig = {
      Type = "simple";
      User = "magnus"; # Your username
      Environment = "DISPLAY=:0";
    };
    
    # Make sure the service is triggered at boot
    wantedBy = [ "multi-user.target" ];
  };


  environment.etc."show-i3-keybindings.sh".text = ''
      #!/run/current-system/sw/bin/bash

      debug_file="/tmp/debug.txt"

      echo "----- Start Debugging -----" >> $debug_file

      keybindings=$(grep 'bindsym' ~/.config/i3/config)
      echo "Keybindings: $keybindings" >> $debug_file

      formatted=$(echo -e "$keybindings" | awk '{$1=""; print $0}' | sed 's/^ //')
      echo "Formatted: $formatted" >> $debug_file

      formatted_keybindings=$(echo -e "$formatted" | sed ':a;N;$!ba;s/\n/\\n/g')
      echo "Formatted Keybindings: $formatted_keybindings" >> $debug_file

      yad --info --title="i3 Keybindings" --text="$formatted_keybindings" --width=600 --height=400 --button="OK":0

      echo "----- End Debugging -----" >> $debug_file

    '';
  environment.etc."show-i3-keybindings.sh".mode = "0755";


  environment.systemPackages = with pkgs; [
    # Python packages
    

    # Normal Nix packages
    vscode
    wget
    curl
    microsoft-edge

    # i3
    i3status
    rofi
    #i3-rounded
    i3lock
    #i3nator
    #i3lock-blur
    
    
    # iphone 
    libimobiledevice
    usbmuxd

    _1password-gui
    shell_gpt
    chatgpt-cli
    fish
    zsh
    neovim
    home-manager
    tmux
    gnome.nautilus
    alacritty
    shutter
    xorg.xrandr
    autorandr
    arandr
    yad
    copyq
    pavucontrol
    pipewire
    pkgs.xbanish
    openvpn
    docker-compose
    vlc
    etcher
    libreoffice
    filezilla
    fira-code
    neofetch
    nmap
    browsh
    bitwig-studio
    pipx
    xorg.xset
  ];



nixpkgs.config.permittedInsecurePackages = [
    "electron-12.2.3"
  ];

  # Fix pipx og pip
  environment.shellInit = ''
    pipx ensurepath
  '';

  
  environment.sessionVariables = {
    WLR_NO_HARDWARE_CURSORS = "1";
    NIXOS_OZONE_WL = "1";
    OPENAI_API_KEY = "";
  };

  hardware = {
  opengl.enable = true;
  };



  # Enable i3
  services.xserver = {
    layout = "no";
    xkbVariant = "nodeadkeys";
  };

  services.xserver.windowManager.i3.enable = true;
  services.xserver.windowManager.i3.extraPackages = with pkgs; [ rofi i3status i3-auto-layout i3lock];
  services.xserver.enable = true;
  services.xserver.displayManager.defaultSession = "none+i3";
  services.xserver.displayManager.lightdm.enable = true;

  hardware.opengl.driSupport32Bit = true;
  
  services.xserver.displayManager.sessionCommands = ''
  ${pkgs.xorg.xset}/bin/xset r rate 200 60
  '';


  # Audio Config
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
  };


  programs.fish.enable = true;

  services.printing.enable = true;

users.users.magnus = {
  isNormalUser = true;
  description = "magnus lislevatn";
  extraGroups = [ "networkmanager" "wheel" "audio" ];
  shell = pkgs.fish;
  packages = with pkgs; [
  
  ];
};


  # Fonts
  fonts.fonts = with pkgs; [
    fira-code
    fira
    cooper-hewitt
    ibm-plex
    jetbrains-mono
    iosevka
    # bitmap
    spleen
    fira-code-symbols
    powerline-fonts
    nerdfonts
  ];

  # Docker
  virtualisation.docker.enable = true;

  # Steam
   programs.steam.enable = true;

  system.autoUpgrade.enable = true;
  system.autoUpgrade.allowReboot = true;
  nixpkgs.config.allowUnfree = true;
  system.stateVersion = "23.05";
}