Nixos module flake

I have been a fan/user of garuda for years (big thanks)… I have been switching OS lately and found NixOS. I would love to have Garuda running again through nixos. I have been playing with configuration.nix for a while. Have a basic understanding of flakes.
I have followed the wiki for nixos moduIe but am getting errors. I have tried some of the configurations in the other posts here in this category without luck. I am hoping someone can fill in the blanks.

I get this error after running nixos-rebuild switch

error: flake ‘path:/etc/nixos’ does not provide attribute ‘packages.x86_64-linux.nixosConfigurations.“nixos”.config.system.build.nixos-rebuild’, ‘legacyPackages.x86_64-linux.nixosConfigurations.“nixos”.config.system.build.nixos-rebuild’ or ‘nixosConfigurations.“nixos”.config.system.build.nixos-rebuild’

flake.nix
{
  description = "Garuda Flake";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    garuda.url = "gitlab:garuda-linux/garuda-nix-subsystem/stable";
  };

  outputs = { garuda, nixpkgs, ... }: {
    nixosConfigurations = {
      hostname = garuda.lib.garudaSystem {
        system = "x86_64-linux";
        modules = [
          ./configuration.nix # Your system configuration.
        ];
      };
    };
  };
}
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, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

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

  networking.hostName = "nixos"; # 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 flakes permanently in NixOS
  nix.settings.experimental-features = [ "nix-command" "flakes" ];

  # Enable networking
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "America/Regina";

  # Select internationalisation properties.
  i18n.defaultLocale = "en_CA.UTF-8";

  # Configure keymap in X11
  services.xserver.xkb = {
    layout = "us";
    variant = "";
  };

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.jeremy = {
    isNormalUser = true;
    description = "Jeremy";
    extraGroups = [ "networkmanager" "wheel" "docker" ];
    openssh.authorizedKeys.keys = [
      "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDjPfmIeYc
kKk1zlAPzMequzwx2SCKqB5kl53utSt7CHK4L3yj6m7JYGnIhdIAI682PEfHYhywG/K4NWdESoypinzZMcHfVyv+j7Ga4amus2NPi/Cr4NpFzU99+rK2SVe8VTzdQ3tpMEz8LoLyZBwLT3xBzTKueIYMSZqwCa4+9SJdrlJ7afzXzPZgv5WU3JF/KZ4e+kAGPE0rrIYSZC9+JVzRl4VVGY2F9Av56SIojqIE4b/cbiEfSCA3ZNazJtcy+P23ZT06lA0aGEerj1+pNNwqWESoVpfbcNYo4YNxD9GObLRDRNK6enJuta4IBi066Rr131E5GZca71zMR2IVyHpQwGWu24wgPumNfImHBdZNME0kqkNey5sMpliXWhsTayU17Ki5AjT4y2JXWVyqQSNFmvZalSdn4EeKT4In9Wkedn1Rf9P/glLw4xiXLGdrOwl+ngdl0tZkRhZ0AUvxSH+Yl4cykZQgJ1juXnKuKFu+2tHMerl8HoNtsM4Rr2U3VUaBKl2T/Ui1TErn5RnyMk/G87Ikul7wSw4TQOSfeZJ5W0iyxnz/wImuHf6qaGjyvSF1Xu9CNjvaWO4kEdEUyS4sp7yt8sVcgxoed9HzXN+mpxDwW7hojAhqatBHco3zBz+Kp0PMYiCb4VXzxoJDVixNlWLhE0gUlvexcYkfVbQ== jeremy@nixos"
    ];
    shell = pkgs.fish;
    packages = with pkgs; [];
  };

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

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
  #  vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
  #  wget
  docker-compose
  git
  micro
  ];

  # 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;
  # };

  programs.fish.enable = true;
  programs.starship.enable = true;
  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  services.openssh = {
    enable = true;
    # require public key authentication for better security
    settings.PasswordAuthentication = false;
    settings.KbdInteractiveAuthentication = false;
    #settings.PermitRootLogin = "yes";
  };
  # Enable QemuGuest agent
  #virtualisation.qemu.guestAgent.enable = true;
  services.qemuGuest.enable = true;
  services.spice-vdagentd.enable = true;
  virtualisation.docker.rootless = {
    enable = true;
    setSocketVariable = true;
  };

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

  # Fix for fish shell
  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
    '';
  };
  
  # 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?

}
2 Likes

Oh, I’m noticing some things here.

nixosConfigurations = {
      hostname

hostname should be replaced with the actual hostname. When applying the config, do it as follows:

sudo nixos-rebuild switch --flake /etc/nixos#hostname

(Obviously replacing hostname with the name set earlier). The --flake looks for a fitting derivation, and since yours doesn’t expose one as of right now it errors out.

Config looks okay at superficial sight, though I would recommend enabling a DE if planning to use it with a GUI, maybe you don’t given the ssh keys and docker compose.

Always happy to see the Nix users around, nice! :slight_smile:

6 Likes

I just want to say thanks. I have added sddm and plasma6. Is there a place where we can find all of the configurations such as …

  garuda = {
    dr460nized.enable = true;
    gaming.enable = true;
    performance-tweaks = {
      cachyos-kernel = true;
      enable = true;
2 Likes

As of now, in fact it’s not documented anywhere but the modules files themselves haha. A short manual for working with them, e.g.:

I have to admit its not very userfriendly without a proper search, but it teaches you the Nix quite well on the way. I learned a lot while reading other people’s flakes as well :wink:

4 Likes

I had to manually find the garuda nix repo figure out how its structured and where this and that are to find that. Having never used nix before. And I only found it when there was that one issue on garuda.excludes.home-manager-modules.excludeAll = true; but it brought back the fun that arch was not giving me.

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.