Entry

NixOS: Import nix files

Solution

# configuration.nix
# _module.args import
{ config, lib, pkgs, ssh_keys, ... }:

{
  # File import itself
  imports = [
    ./base-config.nix
  ];
  
  users.users.yourname = {
    uid = 1001;
    isNormalUser = true;
    extraGroups = [ "wheel" ];
    openssh.authorizedKeys.keys = ssh_keys;
    packages = with pkgs; [
      htop
    ] ++ extraPackages;
  };
}
# base-config.nix
{ config, pkgs, ... }:

{
  _module.args = {
    # If this file is imported, the following imports become available
    ssh_keys = [ "ssh-ed25519 +5MWqxhi... user@device"  "ssh-ed25519 AAAA... user2@device2"];
    
    extraPackages = (with pkgs; [
      ffmpeg-full
    ]);
  };

  # If this file is imported, the settings below will be applied to your configuration automatically
  services.xserver.xkb = {
    layout = "be";
    variant = "nodeadkeys";
  };

  time.timeZone = "Europe/Brussels";
  i18n.defaultLocale = "en_GB.UTF-8";
  console.keyMap = "be-latin1";  # Configure console keymap
}