Yeah, as the others said, this is what we in the scene call “holding it wrong”. Just in those two files you’re evaluating nixpkgs 5 times; that’s ~2G of memory use, not to speak of the evaluation time impact.
To elaborate on @NobbZ earlier suggestions to fix your flake, the idiomatic approach with flakes would look something like this:
# flake.nix
{
inputs = {
nixpkgs.url = "https://channels.nixos.org/nixos-25.11/nixexprs.tar.xz";
atmos-gui = {
url = "/etc/nixos/packages/gui-application";
inputs.nixpkgs.follows = "nixpkgs";
};
print-metadata = {
url = "/etc/nixos/packages/print-metadata";
inputs.nixpkgs.follows = "nixpkgs";
};
modify-update-ssh-keys = {
url = "/etc/nixos/packages/modify-update-ssh-keys";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ nixpkgs, ... }@inputs:
{
nixosConfigurations.hostname = nixpkgs.lib.nixosSystem {
modules = [ ./configuration.nix ];
specialArgs.flake-inputs = inputs;
};
};
}
# configuration.nix
{
pkgs,
lib,
modulesPath,
flake-inputs,
...
}:
let
# Note, by the way, that the `default` flake attributes are
# deprecated. You'd want to update this to be:
#
# flake-inputs.atmos-gui.packages.${pkgs.stdenv.hostPlatform.system}.atmos-gui
atmos-gui = flake-inputs.atmos-gui.defaultPackage.${pkgs.stdenv.hostPlatform.system};
in
{
imports = [
./boot.nix
./users.nix
./metadata.nix
./packages.nix
./networking.nix
./filesystems.nix
./environment.nix
./firmware.nix
(modulesPath + "/profiles/hardened.nix")
];
nix = {
package = pkgs.nix;
settings.experimental-features = [
"nix-command"
"flakes"
];
extraOptions = ''
experimental-features = nix-command flakes
'';
};
i18n.defaultLocale = "en_US.UTF-8";
console = {
earlySetup = true;
font = "ter-932n";
packages = with pkgs; [ terminus_font ];
keyMap = "us";
};
#services.cage.enable = true;
#programs.dconf.enable = true;
hardware.graphics.enable = true;
fonts.fontconfig.enable = true;
services.spice-vdagentd.enable = true;
services.qemuGuest.enable = true;
security.allowSimultaneousMultithreading = true;
security.lockKernelModules = false;
# App armor will be added later
security.apparmor.enable = false;
fonts.packages = with pkgs; [
dejavu_fonts
noto-fonts
noto-fonts-cjk-sans
noto-fonts-color-emoji
];
services.cage = {
enable = true;
user = "atm";
program = lib.getExe atmos-gui;
# This unfortunately makes wayland use a software renderer
# This is ofcourse unacceptable on a bare metal install
# However, this is the only thing that could get the cursed virtio driver to work
# This is so that it looks better when ATM-OS is run inside of a VM
# The QXL driver that causes too much flickering
environment = {
WLR_RENDERER = "pixman";
};
extraArguments = [
"-d"
"-s"
];
};
time.timeZone = "Africa/Cairo";
}
# packages.nix
{
pkgs,
lib,
flake-inputs,
...
}:
{
environment.systemPackages = lib.attrValues {
inherit (pkgs) cage grub2 neovim;
inherit (flake-inputs.print-metadata.packages.${pkgs.stdenv.hostPlatform.system}) print-metadata;
inherit (flake-inputs.modify-update-ssh-keys.packages.${pkgs.stdenv.hostPlatform.system})
modify-update-ssh-keys
;
atmos-gui = flake-inputs.atmos-gui.defaultPackage.${pkgs.stdenv.hostPlatform.system};
};
}
If you’re wondering where your module args went; they were all unused.
This would already cut down the number of nixpkgs evals from these two files to 1 (assuming your other flakes aren’t also silly, which given the long evaluation times, they probably are). That’d bring down memory usage to a more “reasonable” few hundred megs (yes, @7c6f434c is right that nixpkgs eval is way too expensive).
Also, yep, drop the --impure flag. If you need it, that means you’re doing something wrong. The above definitions do not need --impure for anything.
After that, I’d also agree with @NobbZ that you should consolidate the various third “package” flakes. Honestly, it looks like they’re all already part of the /etc/nixos flake anyway, there’s no reason to make them subflakes, just vendor the code, those look like simple scripts. There’s probably no reason to break them into a separate flake; though if there is, you should probably do this differently to begin with.