Skip to content

Instantly share code, notes, and snippets.

@zimbatm
Created December 7, 2021 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zimbatm/dd02c8ce5e4b6af8ddf5a74bbb59655c to your computer and use it in GitHub Desktop.
Save zimbatm/dd02c8ce5e4b6af8ddf5a74bbb59655c to your computer and use it in GitHub Desktop.
{ system ? builtins.currentSystem
, baseModulesFile ? ../nixos/modules/module-list.nix
}:
let
evalNixOS = import ../nixos/lib/eval-config.nix {
system = system;
baseModules = import baseModulesFile;
modules = [
({ modulesPath, ... }: {
# these are required for nixos to evaluate
boot.loader.systemd-boot.enable = true;
fileSystems."/".fsType = "tmpfs";
})
];
};
in
evalNixOS.config.system.build
#!/usr/bin/env ruby
require "json"
require "pathname"
require "pp"
require "tempfile"
def test(modules)
# Write the modules to a file as nix code
tmpfile = Tempfile.new
tmpfile.puts "["
modules.each do |path|
tmpfile.puts " #{path}"
end
tmpfile.puts "]"
tmpfile.flush
system("nix-instantiate baseline.nix --arg baseModulesFile #{tmpfile.path} -A toplevel")
end
PWD = Pathname.pwd
needed = []
modules = JSON.load `nix-instantiate --eval --expr '(map toString (import ../nixos/modules/module-list.nix))' --strict --json`
while modules.size > 0 do
try = modules.sample
modules.delete(try)
puts "# testing #{try}"
if !test(needed + modules)
# keep it, it's needed
needed.push try
end
p modules.size, needed
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment