master @ 165 LINES
[ HISTORY ] [ UP ]
┌─ NIX ──────────────────────────────────────────────────────────────────────┐
│ { │
│ lib, │
│ classes, │
│ encounter, │
│ buffs, │
│ debuffs, │
│ inputs, │
│ trinket, │
│ ... │
│ }: let │
│ config = import ./config.nix {inherit encounter;}; │
│ │
│ # Utility functions │
│ generateScenarios = targetConfigs: durations: │
│ lib.flatten (lib.mapAttrsToList ( │
│ targetCount: targetConfig: │
│ map (duration: { │
│ inherit targetCount duration; │
│ inherit (targetConfig) template; │
│ encounter = targetConfig.encounters.${duration}; │
│ }) │
│ durations │
│ ) │
│ targetConfigs); │
│ │
│ scenarios = generateScenarios config.targetConfigs config.durations; │
│ makeMassSimName = phase: targetCount: duration: "dps-${phase}-raid-${targetCount │
│ }-${duration}"; │
│ │
│ # Function to generate mass simulations with pkgs │
│ generateMassSimulations = pkgs: let │
│ massSimFunctions = import ./mkMassSim.nix {inherit lib pkgs classes encounter │
│ buffs debuffs inputs;}; │
│ inherit (massSimFunctions) mkMassSim; │
│ in │
│ lib.listToAttrs (lib.flatten (map ( │
│ phase: │
│ map (scenario: { │
│ name = makeMassSimName phase scenario.targetCount scenario.duration; │
│ value = mkMassSim { │
│ inherit (config.common) iterations specs encounterType; │
│ inherit (scenario) encounter targetCount duration template; │
│ inherit phase; │
│ }; │
│ }) │
│ scenarios │
│ ) │
│ config.phases)); │
│ │
│ # Function to generate race comparisons with pkgs │
│ generateRaceComparisons = pkgs: let │
│ massSimFunctions = import ./mkMassSim.nix {inherit lib pkgs classes encounter │
│ buffs debuffs inputs;}; │
│ inherit (massSimFunctions) mkRaceComparison; │
│ in │
│ lib.listToAttrs (lib.flatten (map ( │
│ specConfig: │
│ map (scenario: { │
│ name = "race-${specConfig.class}-${specConfig.spec}-p1-raid-${scenario │
│ .targetCount}-${scenario.duration}"; │
│ value = mkRaceComparison { │
│ inherit (specConfig) class spec; │
│ inherit (scenario) encounter targetCount duration template; │
│ inherit (config.common) encounterType iterations; │
│ # only simulate race benchmarks for p1 │
│ phase = "p1"; │
│ }; │
│ }) │
│ scenarios │
│ ) │
│ config.raceComparisonSpecs)); │
│ │
│ # Function to generate trinket comparisons with pkgs │
│ generateTrinketComparisons = pkgs: let │
│ trinketComparison = import ./mkTrinketComparison.nix {inherit lib pkgs classes │
│ encounter buffs debuffs inputs trinket;}; │
│ inherit (trinketComparison) mkTrinketComparison; │
│ in │
│ lib.listToAttrs (lib.flatten (map ( │
│ specConfig: │
│ map (scenario: { │
│ name = "trinket-${specConfig.class}-${specConfig.spec}-p1-raid-${scena │
│ rio.targetCount}-${scenario.duration}"; │
│ value = mkTrinketComparison { │
│ inherit (specConfig) class spec trinketCategory; │
│ inherit (scenario) encounter duration template targetCount; │
│ inherit (config.common) encounterType iterations; │
│ phase = "p1"; │
│ }; │
│ }) │
│ scenarios │
│ ) │
│ config.trinketComparisonSpecs)); │
│ │
│ # Function to generate test group simulation with pkgs │
│ generateTestGroupSim = pkgs: let │
│ testGroupSim = import ./mkTestGroupSim.nix {inherit lib pkgs classes encounter │
│ buffs debuffs inputs;}; │
│ in │
│ testGroupSim.mkTestGroupScript; │
│ │
│ # Function to generate all simulations script with pkgs │
│ generateAllSimulationsScript = pkgs: let │
│ massSimulations = generateMassSimulations pkgs; │
│ raceComparisons = generateRaceComparisons pkgs; │
│ trinketComparisons = generateTrinketComparisons pkgs; │
│ in │
│ pkgs.writeShellApplication { │
│ name = "all-simulations"; │
│ text = '' │
│ echo "Running all WoW simulations..." │
│ │
│ echo "" │
│ echo "=== DPS Rankings ===" │
│ ${lib.concatMapStringsSep "\n" (name: '' │
│ echo "" │
│ echo "Running ${name}..." │
│ ${massSimulations.${name}.script}/bin/${massSimulations.${name}.metadata │
│ .output}-aggregator │
│ '') (lib.attrNames massSimulations)} │
│ │
│ echo "" │
│ echo "=== Race Comparisons ===" │
│ ${lib.concatMapStringsSep "\n" (name: '' │
│ echo "" │
│ echo "Running ${name}..." │
│ ${raceComparisons.${name}.script}/bin/${raceComparisons.${name}.metadata │
│ .output}-aggregator │
│ '') (lib.attrNames raceComparisons)} │
│ │
│ echo "" │
│ echo "=== Trinket Comparisons ===" │
│ ${lib.concatMapStringsSep "\n" (name: '' │
│ echo "" │
│ echo "Running ${name}..." │
│ ${trinketComparisons.${name}.script}/bin/${trinketComparisons.${name}.me │
│ tadata.output}-aggregator │
│ '') (lib.attrNames trinketComparisons)} │
│ │
│ echo "" │
│ echo "All simulations completed successfully!" │
│ echo "" │
│ echo "Generated DPS rankings:" │
│ ls -la web/public/data/rankings/*.json 2>/dev/null || echo "No ranking fil │
│ es found" │
│ echo "" │
│ echo "Generated race comparisons:" │
│ find web/public/data/comparison/race -name "*.json" 2>/dev/null || echo "N │
│ o race comparison files found" │
│ echo "" │
│ echo "Generated trinket comparisons:" │
│ find web/public/data/comparison/trinkets -name "*.json" 2>/dev/null || ech │
│ o "No trinket comparison files found" │
│ ''; │
│ runtimeInputs = [pkgs.coreutils pkgs.findutils]; │
│ }; │
│ │
│ # Function to generate simulation inputs with pkgs │
│ generateSimInputs = pkgs: let │
│ simInputsModule = import ./inputs.nix {inherit lib pkgs classes encounter buff │
│ s debuffs inputs trinket;}; │
│ in │
│ simInputsModule.simInputs; │
│ │
│ simulation = { │
│ # Generation functions that take pkgs as parameter │
│ inherit generateMassSimulations generateRaceComparisons generateTrinketCompari │
│ sons generateAllSimulationsScript generateTestGroupSim generateSimInputs; │
│ │
│ # Configuration and utilities │
│ inherit config generateScenarios scenarios; │
│ │
│ # Helper functions │
│ inherit makeMassSimName; │
│ }; │
│ in { │
│ flake.simulation = simulation; │
│ _module.args.simulation = simulation; │
│ } │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ NIX ────────────────────────────────┐
│ { │
│ lib, │
│ classes, │
│ encounter, │
│ buffs, │
│ debuffs, │
│ inputs, │
│ trinket, │
│ ... │
│ }: let │
│ config = import ./config.nix {inherit enco │
│ unter;}; │
│ │
│ # Utility functions │
│ generateScenarios = targetConfigs: duratio │
│ ns: │
│ lib.flatten (lib.mapAttrsToList ( │
│ targetCount: targetConfig: │
│ map (duration: { │
│ inherit targetCount duration; │
│ inherit (targetConfig) template; │
│ encounter = targetConfig.encount │
│ ers.${duration}; │
│ }) │
│ durations │
│ ) │
│ targetConfigs); │
│ │
│ scenarios = generateScenarios config.targe │
│ tConfigs config.durations; │
│ makeMassSimName = phase: targetCount: dura │
│ tion: "dps-${phase}-raid-${targetCount}-${du │
│ ration}"; │
│ │
│ # Function to generate mass simulations wi │
│ th pkgs │
│ generateMassSimulations = pkgs: let │
│ massSimFunctions = import ./mkMassSim.ni │
│ x {inherit lib pkgs classes encounter buffs │
│ debuffs inputs;}; │
│ inherit (massSimFunctions) mkMassSim; │
│ in │
│ lib.listToAttrs (lib.flatten (map ( │
│ phase: │
│ map (scenario: { │
│ name = makeMassSimName phase sce │
│ nario.targetCount scenario.duration; │
│ value = mkMassSim { │
│ inherit (config.common) iterat │
│ ions specs encounterType; │
│ inherit (scenario) encounter t │
│ argetCount duration template; │
│ inherit phase; │
│ }; │
│ }) │
│ scenarios │
│ ) │
│ config.phases)); │
│ │
│ # Function to generate race comparisons wi │
│ th pkgs │
│ generateRaceComparisons = pkgs: let │
│ massSimFunctions = import ./mkMassSim.ni │
│ x {inherit lib pkgs classes encounter buffs │
│ debuffs inputs;}; │
│ inherit (massSimFunctions) mkRaceCompari │
│ son; │
│ in │
│ lib.listToAttrs (lib.flatten (map ( │
│ specConfig: │
│ map (scenario: { │
│ name = "race-${specConfig.class} │
│ -${specConfig.spec}-p1-raid-${scenario.targe │
│ tCount}-${scenario.duration}"; │
│ value = mkRaceComparison { │
│ inherit (specConfig) class spe │
│ c; │
│ inherit (scenario) encounter t │
│ argetCount duration template; │
│ inherit (config.common) encoun │
│ terType iterations; │
│ # only simulate race benchmark │
│ s for p1 │
│ phase = "p1"; │
│ }; │
│ }) │
│ scenarios │
│ ) │
│ config.raceComparisonSpecs)); │
│ │
│ # Function to generate trinket comparisons │
│ with pkgs │
│ generateTrinketComparisons = pkgs: let │
│ trinketComparison = import ./mkTrinketCo │
│ mparison.nix {inherit lib pkgs classes encou │
│ nter buffs debuffs inputs trinket;}; │
│ inherit (trinketComparison) mkTrinketCom │
│ parison; │
│ in │
│ lib.listToAttrs (lib.flatten (map ( │
│ specConfig: │
│ map (scenario: { │
│ name = "trinket-${specConfig.cla │
│ ss}-${specConfig.spec}-p1-raid-${scenario.ta │
│ rgetCount}-${scenario.duration}"; │
│ value = mkTrinketComparison { │
│ inherit (specConfig) class spe │
│ c trinketCategory; │
│ inherit (scenario) encounter d │
│ uration template targetCount; │
│ inherit (config.common) encoun │
│ terType iterations; │
│ phase = "p1"; │
│ }; │
│ }) │
│ scenarios │
│ ) │
│ config.trinketComparisonSpecs)); │
│ │
│ # Function to generate test group simulati │
│ on with pkgs │
│ generateTestGroupSim = pkgs: let │
│ testGroupSim = import ./mkTestGroupSim.n │
│ ix {inherit lib pkgs classes encounter buffs │
│ debuffs inputs;}; │
│ in │
│ testGroupSim.mkTestGroupScript; │
│ │
│ # Function to generate all simulations scr │
│ ipt with pkgs │
│ generateAllSimulationsScript = pkgs: let │
│ massSimulations = generateMassSimulation │
│ s pkgs; │
│ raceComparisons = generateRaceComparison │
│ s pkgs; │
│ trinketComparisons = generateTrinketComp │
│ arisons pkgs; │
│ in │
│ pkgs.writeShellApplication { │
│ name = "all-simulations"; │
│ text = '' │
│ echo "Running all WoW simulations... │
│ " │
│ │
│ echo "" │
│ echo "=== DPS Rankings ===" │
│ ${lib.concatMapStringsSep "\n" (name │
│ : '' │
│ echo "" │
│ echo "Running ${name}..." │
│ ${massSimulations.${name}.script}/ │
│ bin/${massSimulations.${name}.metadata.outpu │
│ t}-aggregator │
│ '') (lib.attrNames massSimulations)} │
│ │
│ echo "" │
│ echo "=== Race Comparisons ===" │
│ ${lib.concatMapStringsSep "\n" (name │
│ : '' │
│ echo "" │
│ echo "Running ${name}..." │
│ ${raceComparisons.${name}.script}/ │
│ bin/${raceComparisons.${name}.metadata.outpu │
│ t}-aggregator │
│ '') (lib.attrNames raceComparisons)} │
│ │
│ echo "" │
│ echo "=== Trinket Comparisons ===" │
│ ${lib.concatMapStringsSep "\n" (name │
│ : '' │
│ echo "" │
│ echo "Running ${name}..." │
│ ${trinketComparisons.${name}.scrip │
│ t}/bin/${trinketComparisons.${name}.metadata │
│ .output}-aggregator │
│ '') (lib.attrNames trinketComparison │
│ s)} │
│ │
│ echo "" │
│ echo "All simulations completed succ │
│ essfully!" │
│ echo "" │
│ echo "Generated DPS rankings:" │
│ ls -la web/public/data/rankings/*.js │
│ on 2>/dev/null || echo "No ranking files fou │
│ nd" │
│ echo "" │
│ echo "Generated race comparisons:" │
│ find web/public/data/comparison/race │
│ -name "*.json" 2>/dev/null || echo "No race │
│ comparison files found" │
│ echo "" │
│ echo "Generated trinket comparisons: │
│ " │
│ find web/public/data/comparison/trin │
│ kets -name "*.json" 2>/dev/null || echo "No │
│ trinket comparison files found" │
│ ''; │
│ runtimeInputs = [pkgs.coreutils pkgs.f │
│ indutils]; │
│ }; │
│ │
│ # Function to generate simulation inputs w │
│ ith pkgs │
│ generateSimInputs = pkgs: let │
│ simInputsModule = import ./inputs.nix {i │
│ nherit lib pkgs classes encounter buffs debu │
│ ffs inputs trinket;}; │
│ in │
│ simInputsModule.simInputs; │
│ │
│ simulation = { │
│ # Generation functions that take pkgs as │
│ parameter │
│ inherit generateMassSimulations generate │
│ RaceComparisons generateTrinketComparisons g │
│ enerateAllSimulationsScript generateTestGrou │
│ pSim generateSimInputs; │
│ │
│ # Configuration and utilities │
│ inherit config generateScenarios scenari │
│ os; │
│ │
│ # Helper functions │
│ inherit makeMassSimName; │
│ }; │
│ in { │
│ flake.simulation = simulation; │
│ _module.args.simulation = simulation; │
│ } │
└──────────────────────────────────────────────┘
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET