Created
December 7, 2021 14:34
-
-
Save zimbatm/dd02c8ce5e4b6af8ddf5a74bbb59655c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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