Error: attribute 'default' missing

so “I” made a flake for installing Legacy Launcher (a Minecraft Launcher) which is available at this Github repo and when I’m trying to import it it gives me the following error:

       error: attribute 'default' missing
       at /nix/store/07pvibniw3hpv64gcjh911rmh3csrv7s-source/configuration.nix:154:12:
          153|         mangohud
          154|         "${inputs.legacylauncher.packages.${pkgs.system}.default}"
             |            ^
          155|         libreoffice-fresh

I have been trying to find a solution using ChatGPT and that was of no help.
here is my system flake.nix:

{
  description = "Nixos config flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    
    # Home-manager for managing home configuration
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs"; # Use system packages list where available
    };
    
    # Add your legacylauncher flake input
    legacylauncher.url = "github:rminstrel/llaunch-nixos";
    
    # Community packages; used for Firefox extensions
    nur.url = "github:nix-community/nur";
  };

  outputs = { self, nixpkgs, home-manager, nur, legacylauncher }@inputs: {
    nixosConfigurations.default = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      specialArgs = { inherit inputs; };
      modules = [
        ./configuration.nix
        inputs.home-manager.nixosModules.default
      ];
    };
  };
}

and my configuration.nix:

# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, lib, inputs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      ./flatpak.nix
      inputs.home-manager.nixosModules.default   
    ];

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

  networking.hostName = "hp-15s-du1015tu"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Enable networking
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "Asia/Dhaka";

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

  # Set the environment variables
  environment.sessionVariables = {
  EDITOR = "micro";
  };

  # Enable the X11 windowing system.
  services.xserver.enable = true;

  # Enable the GNOME Desktop Environment.
  services.xserver.displayManager.gdm.enable = true;
  services.xserver.desktopManager.gnome.enable = true;
  environment.gnome.excludePackages = with pkgs; [
    gnome-contacts
    gnome-weather
    gnome-maps
    gnome-clocks
    gnome-text-editor
    gnome-tour
    gnome-music
    gnome-calendar
    gnome-console
    gnome-calculator
    gnome-logs
    gnome-connections
    gnome-software
    geary
    loupe
    totem
    seahorse
    epiphany
  ];
  programs.gnome-terminal.enable = false;

  # Set Qt styling
  qt = {
    enable = true;
    style = "adwaita-dark";
    platformTheme = "gnome";
  };

  # Configure keymap in X11
  services.xserver.xkb = {
    layout = "us";
    variant = "";
    options = "caps:escape";
    model = "pc86";
  };

  # Configure kanata
  services.kanata = {
    enable = true;
    keyboards = {
      "hp-kbd".config = ''
(defsrc
  grv  1    2    3    4    5    6    7    8    9    0    -    =    bspc
  tab  q    w    e    r    t    y    u    i    o    p    [    ]    \
  caps a    s    d    f    g    h    j    k    l    ;    '    ret
  lsft z    x    c    v    b    n    m    ,    .    /    rsft
  lctl lmet lalt           spc            ralt rmet rctl
)

(deflayer qwerty
  grv  1    2    3    4    5    6    7    8    9    0    -    =    bspc
  tab  q    w    e    r    t    y    u    i    o    p    [    ]    \
  esc  a    s    d    f    g    h    j    k    l    ;    '    ret
  lsft z    x    c    v    b    n    m    ,    .    /    rsft
  lctl lmet lalt           spc            ralt rmet rctl
)
  '';
    };
  };

  # Enable CUPS to print documents.
  services.printing.enable = true;

  # Enable sound with pipewire.
  services.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    jack.enable = true;

    # use the example session manager (no others are packaged yet so this is enabled by default,
    # no need to redefine it in your config for now)
    # media-session.enable = true;
  };

  # Enable touchpad support (enabled default in most desktopManager).
  # services.xserver.libinput.enable = true;

  # Define a user account. Don't forget to set a password with ‘passwd’.
    users.users.rminstrel = {
      isNormalUser = true;
      description = "Alif Al Amin";
      extraGroups = [ "networkmanager" "wheel" "podman" ];
      packages = with pkgs; [
	    	thunderbird
        fastfetch
        steam
        steam-run
	    	adwsteamgtk
        lutris-unwrapped
        gamescope
        mangohud
        "${inputs.legacylauncher.packages.${pkgs.system}.default}"
        libreoffice-fresh
        discord
        obs-studio
        davinci-resolve
        audacity
        gimp-with-plugins
        inkscape-with-extensions
        ollama
        alpaca
        shotwell
        vlc
        rhythmbox
        qbittorrent
        vscodium
    ];
  };

  # Install home-manager for declaring home configurations
  home-manager = {
    # also pass inputs to home-manager modules
    extraSpecialArgs = {inherit inputs;};
    users = {
      "rminstrel" = import ./home-manager/home.nix;
    };
  };

  # getty autologin for rminstrel
  services.getty.autologinUser = "rminstrel";

  # Enable podman for containers
  virtualisation = {
    containers.enable = true;
    podman = {
      enable = true;
      dockerCompat = true;
      defaultNetwork.settings.dns_enabled = true;
    };
  };

  # Install and configure flatpak
  services.flatpak.enable = true;
  xdg.portal = {
    extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
    config.common.default = "gtk";
  };

  # Install firefox.
  programs.firefox.enable = true;

  # Allow unfree packages
  nixpkgs.config.allowUnfree = true;

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
    micro
    neovim
    wget
    curl
    git
    links2
    wl-clipboard
    wl-clipboard-x11
    wineWowPackages.waylandFull
    winetricks
    kanata-with-cmd
    kdePackages.qt6ct
    adwaita-qt
    adwaita-qt6
    dconf-editor
    gnome-tweaks
    tilix
    pods
    # legacylauncher.defaultPackage  # Add legacylauncher to system packages
  ];

  # Some kernel shenanigans
  boot.kernelParams = [ "rw" "rootfstype=ext4" "loglevel=7" "debug" "pcie_aspm=off" "pci=noaer" "mitigations=off" "sysrq_always_enabled=1" "i915.modeset=1" ];

  # Fix that damn lid on HP laptops
  systemd.services.hp-keycodes = {
    description = "HP setkeycodes fix";
    serviceConfig = {
      Type = "oneshot";
      ExecStart = [ "${pkgs.kbd}/bin/setkeycodes e057 240 e058 240" ];
      RemainAfterExit = "no";
    };
    wantedBy = [ "rescue.target" "multi-user.target" "graphical.target" ];
  };

  # Some nix settings to improve performance and build times
  nix.settings = {
    auto-optimise-store = true;
    show-trace = true;
    experimental-features = [ "nix-command" "flakes" ];
    substituters = [ "https://aseipp-nix-cache.global.ssl.fastly.net" "https://nix-community.cachix.org" "https://mirror.sjtu.edu.cn/nix-channels/store" ];
    trusted-public-keys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" ];
  };

  # OpenGL shenanigans
  hardware.graphics = {
    enable = true;
    enable32Bit = true;
    extraPackages = with pkgs; [ intel-media-driver intel-compute-runtime vulkan-tools aha pciutils wayland-utils glxinfo egl-wayland ];
    # extraPackages32 = with pkgs; [ intel-media-driver intel-compute-runtime vulkan-tools aha pciutils wayland-utils glxinfo egl-wayland ];
  };

  # Remove nano because it sucks balls
  programs.nano.enable = false;

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  programs.gnupg.agent = {
    enable = true;
    enableSSHSupport = true;
  };

  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  services.openssh.enable = true;

  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  # 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 = "24.11"; # Did you read the comment?

}

What did “I” do wrong? Would be helpful if someone suggests a fix. I’m extremely new to NixOS and just got my NixOS configs backed up to my Git repo here

It doesn’t look like that flake sets a packages.<system>.default, have you tried .legacylauncher instead of .default?

Yes, but now I’m trying .legacylauncher instead of .default and it still errors out because apparently my package has an “unfree”. Even though I have changed the licenses to “free”: as seen below:

 meta = with pkgs.lib; {
    description = "Legacy Launcher is a simple and lightweight Minecraft launcher";
    homepage = "https://llaun.ch";
    license = licenses.free;
    maintainers = with maintainers; [ turikhay rminstrel chatgpt ];
  };

It errors out and says:


       a) To temporarily allow unfree packages, you can use an environment variable
          for a single invocation of the nix tools.

            $ export NIXPKGS_ALLOW_UNFREE=1

          Note: When using `nix shell`, `nix build`, `nix develop`, etc with a flake,
                then pass `--impure` in order to allow use of environment variables.

       b) For `nixos-rebuild` you can set
         { nixpkgs.config.allowUnfree = true; }
       in configuration.nix to override this.

       Alternatively you can configure a predicate to allow specific packages:
         { nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
             "legacylauncher"
           ];
         }

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
         { allowUnfree = true; }
       to ~/.config/nixpkgs/config.nix.

For some reason, even though I ran sudo nix-clean-garbage --delete-old the problem persists.

Your error doesn’t make sense based on the content of the package - gpl3 is already a free license. Most likely you didn’t run nix flake update after you updated the upstream flake.

Also:

  • You should be using pkgs.callPackage <path> { }, not import <path> { ... }, see Package parameters and overrides with callPackage — nix.dev documentation
  • Ideally you also use the attributes within pkgs, not pkgs itself as the expression argument
  • You must specify either name or both pname and version
  • You cannot access the network within a derivation that’s not a FOD, use separate fetchers for each thing you need to fetch
1 Like

Well, those issues were indeed resolved through sudo nix flake update and I was able to install the launcher “successfully” but again the bootstrap needs to be copied over so it errored out stating that /nix/store is ROFS (I mean it’s correct)

Now I am trying to extract the bootstrap to a directory inside my home directory using $HOME but then Nix tries to extract the bootstrap to /homeless-shelter, which I assume is from the lack of the value of the $HOME variable. What should I actually do in llaunch-nixos/default.nix?

nix flake update should not generally be done as root, you risk some ownership mismatches there since the repo is (I assume) owned by another user.

export HOME=$(mktemp -d) prior should work, though if you have to then do something with those files, you’ll have to take care of that manually.

mktemp -d just creates a temporary directory for the bootstrap to go to but I’d rather have the bootstrap extracted to my /home/user/.legacylauncher/ install dir since nix store is ROFS and since the launcher also downloads a newer .jar executable when available, merely omitting the part of copying shared bootstrap in $out/bin/legacylauncher won’t help, since the “update” will fail due to the immutability of /nix/store in general. Is there a way that I can install the bootstrap to my specific install directory in my /home directory?

No, build results will only end up in the nix store.
You can use home.file from HM to symlink it to your $HOME if you like.

The thing is that the executable .jar file needs a read-write environment to be stored in, otherwise this error pops up:

[rminstrel@hp-15s-du1015tu:~/Games/Game_Installers/LegacyLauncher]$ legacylauncher 
Starting the launcher
Error: Invalid or corrupt jarfile /nix/store/hr3qngds9pxwgghphhbxm2hll37zn3ca-legacylauncher/lib/legacylauncher/bootstrap.jar

How do i then install this?

Updated default.nix and flake.nix are in the github repo mentioned before.

There is some alternative like using buildFHSEnv the way steam and dropbox do, those are also self-updating apps. Maybe you can look into those?

That still only applies at runtime, and you’d need to copy the jar at runtime anyway since normally it’s mounted into the container. You cannot do what you’re trying to do at build time.

Whether it involves an fhsUserEnv or you simply write a wrapper script that copies the script to somewhere it can be written to, you’ll have to bake a way to do the bootstrap at runtime into the main binary of your package.

That, or you figure out what their bootstrap actually does and reimplement it, scripts like that don’t really mesh well with reproducible packaging to begin with. It’s hardly a nix package if you do most of the work at runtime. It likely just consists of a bunch of cruft for cross-platform support that is largely irrelevant for a nix package.

Whichever way you go, this isn’t going to be a fun package to write.

1 Like