HASH 40f232a73823
DATE 2025-07-19
SUBJECT nix: extend lib
FILES 8 CHANGED
HASH 40f232a73823
DATE 2025-07-19
SUBJECT nix: extend lib
FILES 8 CHANGED
┌─ flake.nix ────────────────────────────────────────────────────────────────┐
│ diff --git a/flake.nix b/flake.nix │
│ index fd4a593..fe61d9e 100644 │
│ --- a/flake.nix │
│ +++ b/flake.nix │
│ @@ -15,8 +15,18 @@ │
│ }; │
│ }; │
│ │
│ - outputs = inputs @ {flake-parts, ...}: │
│ - flake-parts.lib.mkFlake {inherit inputs;} { │
│ + outputs = inputs @ { │
│ + flake-parts, │
│ + self, │
│ + ... │
│ + }: let │
│ + # extend nixpkgs library with our sim library │
│ + lib = import ./nix/lib/extend.nix {inherit inputs self;}; │
│ + in │
│ + flake-parts.lib.mkFlake { │
│ + inherit inputs; │
│ + specialArgs = {inherit lib;}; │
│ + } { │
│ systems = import inputs.systems; │
│ imports = [./nix]; │
│ }; │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ flake.nix ──────────────────────────┐
│ diff --git a/flake.nix b/flake.nix │
│ index fd4a593..fe61d9e 100644 │
│ --- a/flake.nix │
│ +++ b/flake.nix │
│ @@ -15,8 +15,18 @@ │
│ }; │
│ }; │
│ │
│ - outputs = inputs @ {flake-parts, ...}: │
│ - flake-parts.lib.mkFlake {inherit inputs │
│ ;} { │
│ + outputs = inputs @ { │
│ + flake-parts, │
│ + self, │
│ + ... │
│ + }: let │
│ + # extend nixpkgs library with our sim l │
│ ibrary │
│ + lib = import ./nix/lib/extend.nix {inhe │
│ rit inputs self;}; │
│ + in │
│ + flake-parts.lib.mkFlake { │
│ + inherit inputs; │
│ + specialArgs = {inherit lib;}; │
│ + } { │
│ systems = import inputs.systems; │
│ imports = [./nix]; │
│ }; │
└──────────────────────────────────────────────┘
┌─ nix/lib/default.nix ──────────────────────────────────────────────────────┐
│ diff --git a/nix/lib/default.nix b/nix/lib/default.nix │
│ new file mode 100644 │
│ index 0000000..9074507 │
│ --- /dev/null │
│ +++ b/nix/lib/default.nix │
│ @@ -0,0 +1,11 @@ │
│ +{ │
│ + inputs, │
│ + lib, │
│ + ... │
│ +}: { │
│ + # class = import ./class.nix; │
│ + target = import ./target.nix {inherit lib;}; │
│ + encounter = import ./encounter.nix {inherit lib;}; │
│ + player = import ./player.nix {inherit lib inputs;}; │
│ + raid = import ./raid.nix {}; │
│ +} │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ nix/lib/default.nix ────────────────┐
│ diff --git a/nix/lib/default.nix b/nix/lib/d │
│ efault.nix │
│ new file mode 100644 │
│ index 0000000..9074507 │
│ --- /dev/null │
│ +++ b/nix/lib/default.nix │
│ @@ -0,0 +1,11 @@ │
│ +{ │
│ + inputs, │
│ + lib, │
│ + ... │
│ +}: { │
│ + # class = import ./class.nix; │
│ + target = import ./target.nix {inherit lib │
│ ;}; │
│ + encounter = import ./encounter.nix {inher │
│ it lib;}; │
│ + player = import ./player.nix {inherit lib │
│ inputs;}; │
│ + raid = import ./raid.nix {}; │
│ +} │
└──────────────────────────────────────────────┘
┌─ nix/lib/encounters.nix ───────────────────────────────────────────────────┐
│ diff --git a/nix/lib/encounters.nix b/nix/lib/encounters.nix │
│ index 33128fa..6250dd2 100644 │
│ --- a/nix/lib/encounters.nix │
│ +++ b/nix/lib/encounters.nix │
│ @@ -50,4 +50,3 @@ │
│ }; │
│ in │
│ raid │
│ - │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ nix/lib/encounters.nix ─────────────┐
│ diff --git a/nix/lib/encounters.nix b/nix/li │
│ b/encounters.nix │
│ index 33128fa..6250dd2 100644 │
│ --- a/nix/lib/encounters.nix │
│ +++ b/nix/lib/encounters.nix │
│ @@ -50,4 +50,3 @@ │
│ }; │
│ in │
│ raid │
│ - │
└──────────────────────────────────────────────┘
┌─ nix/lib/extend.nix ───────────────────────────────────────────────────────┐
│ diff --git a/nix/lib/extend.nix b/nix/lib/extend.nix │
│ new file mode 100644 │
│ index 0000000..78da3cf │
│ --- /dev/null │
│ +++ b/nix/lib/extend.nix │
│ @@ -0,0 +1,7 @@ │
│ +{inputs, ...} @ args: │
│ +inputs.nixpkgs.lib.extend (self: super: { │
│ + sim = import ./. { │
│ + inherit (args) inputs self; │
│ + lib = self; │
│ + }; │
│ +}) │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ nix/lib/extend.nix ─────────────────┐
│ diff --git a/nix/lib/extend.nix b/nix/lib/ex │
│ tend.nix │
│ new file mode 100644 │
│ index 0000000..78da3cf │
│ --- /dev/null │
│ +++ b/nix/lib/extend.nix │
│ @@ -0,0 +1,7 @@ │
│ +{inputs, ...} @ args: │
│ +inputs.nixpkgs.lib.extend (self: super: { │
│ + sim = import ./. { │
│ + inherit (args) inputs self; │
│ + lib = self; │
│ + }; │
│ +}) │
└──────────────────────────────────────────────┘
┌─ nix/lib/party.nix ────────────────────────────────────────────────────────┐
│ diff --git a/nix/lib/party.nix b/nix/lib/party.nix │
│ new file mode 100644 │
│ index 0000000..f7d5498 │
│ --- /dev/null │
│ +++ b/nix/lib/party.nix │
│ @@ -0,0 +1,12 @@ │
│ +let │
│ + # TODO, dynamically set buffs/debuffs based on specs present │
│ + mkRaid = { │
│ + parties, │
│ + buffs, │
│ + debuffs, │
│ + targetDummies, │
│ + }: { │
│ + inherit parties buffs debuffs targetDummies; │
│ + }; │
│ +in │
│ + mkRaid │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ nix/lib/party.nix ──────────────────┐
│ diff --git a/nix/lib/party.nix b/nix/lib/par │
│ ty.nix │
│ new file mode 100644 │
│ index 0000000..f7d5498 │
│ --- /dev/null │
│ +++ b/nix/lib/party.nix │
│ @@ -0,0 +1,12 @@ │
│ +let │
│ + # TODO, dynamically set buffs/debuffs bas │
│ ed on specs present │
│ + mkRaid = { │
│ + parties, │
│ + buffs, │
│ + debuffs, │
│ + targetDummies, │
│ + }: { │
│ + inherit parties buffs debuffs targetDum │
│ mies; │
│ + }; │
│ +in │
│ + mkRaid │
└──────────────────────────────────────────────┘
┌─ nix/lib/player.nix ───────────────────────────────────────────────────────┐
│ diff --git a/nix/lib/player.nix b/nix/lib/player.nix │
│ new file mode 100644 │
│ index 0000000..62f94f4 │
│ --- /dev/null │
│ +++ b/nix/lib/player.nix │
│ @@ -0,0 +1,52 @@ │
│ +{ │
│ + lib, │
│ + inputs, │
│ + ... │
│ +}: let │
│ + inherit (lib.string) toSentenceCase; │
│ + inherit (inputs) wowsims; │
│ + inherit (builtins) readFile fromJSON; │
│ + mkPlayer = { │
│ + name ? "Player", │
│ + race, │
│ + class, │
│ + spec, │
│ + gearset, │
│ + consumables, │
│ + options, │
│ + talents, │
│ + glyphs, │
│ + profession1, │
│ + profession2, │
│ + apl, │
│ + distanceFromTarget, │
│ + challengeMode ? false, │
│ + reactionTimeMs ? 100, │
│ + }: let │
│ + baseEquipment = fromJSON (readFile "${wowsims}/ui/${class}/${spec}/gear_sets/ │
│ ${gearset}.gear.json"); │
│ + equipment = │
│ + if challengeMode │
│ + then │
│ + baseEquipment │
│ + // { │
│ + items = map (item: item // {challengeMode = true;}) baseEquipment.items │
│ ; │
│ + } │
│ + else baseEquipment; │
│ + │
│ + rotation = fromJSON (readFile "${wowsims}/ui/${class}/${spec}/apls/${apl}.apl │
│ .json"); │
│ + in { │
│ + inherit equipment name consumables glyphs profession1 profession2 rotation re │
│ actionTimeMs distanceFromTarget; │
│ + race = "Race${toSentenceCase race}"; │
│ + class = "Class${toSentenceCase class}"; │
│ + talentString = talents; │
│ + │
│ + "${spec}${toSentenceCase class}" = { │
│ + inherit options; │
│ + }; │
│ + │
│ + # TODO │
│ + cooldowns = {}; │
│ + healingModel = {}; │
│ + }; │
│ +in │
│ + mkPlayer │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ nix/lib/player.nix ─────────────────┐
│ diff --git a/nix/lib/player.nix b/nix/lib/pl │
│ ayer.nix │
│ new file mode 100644 │
│ index 0000000..62f94f4 │
│ --- /dev/null │
│ +++ b/nix/lib/player.nix │
│ @@ -0,0 +1,52 @@ │
│ +{ │
│ + lib, │
│ + inputs, │
│ + ... │
│ +}: let │
│ + inherit (lib.string) toSentenceCase; │
│ + inherit (inputs) wowsims; │
│ + inherit (builtins) readFile fromJSON; │
│ + mkPlayer = { │
│ + name ? "Player", │
│ + race, │
│ + class, │
│ + spec, │
│ + gearset, │
│ + consumables, │
│ + options, │
│ + talents, │
│ + glyphs, │
│ + profession1, │
│ + profession2, │
│ + apl, │
│ + distanceFromTarget, │
│ + challengeMode ? false, │
│ + reactionTimeMs ? 100, │
│ + }: let │
│ + baseEquipment = fromJSON (readFile "${w │
│ owsims}/ui/${class}/${spec}/gear_sets/${gear │
│ set}.gear.json"); │
│ + equipment = │
│ + if challengeMode │
│ + then │
│ + baseEquipment │
│ + // { │
│ + items = map (item: item // {chall │
│ engeMode = true;}) baseEquipment.items; │
│ + } │
│ + else baseEquipment; │
│ + │
│ + rotation = fromJSON (readFile "${wowsim │
│ s}/ui/${class}/${spec}/apls/${apl}.apl.json" │
│ ); │
│ + in { │
│ + inherit equipment name consumables glyp │
│ hs profession1 profession2 rotation reaction │
│ TimeMs distanceFromTarget; │
│ + race = "Race${toSentenceCase race}"; │
│ + class = "Class${toSentenceCase class}"; │
│ + talentString = talents; │
│ + │
│ + "${spec}${toSentenceCase class}" = { │
│ + inherit options; │
│ + }; │
│ + │
│ + # TODO │
│ + cooldowns = {}; │
│ + healingModel = {}; │
│ + }; │
│ +in │
│ + mkPlayer │
└──────────────────────────────────────────────┘
┌─ nix/lib/simulation.nix ───────────────────────────────────────────────────┐
│ diff --git a/nix/lib/simulation.nix b/nix/lib/simulation.nix │
│ new file mode 100644 │
│ index 0000000..3722c21 │
│ --- /dev/null │
│ +++ b/nix/lib/simulation.nix │
│ @@ -0,0 +1,16 @@ │
│ +let │
│ + mkSim = { │
│ + requestId ? "raidSimAsync-b01aabae125f334e", │
│ + type ? "SimTypeIndividual", │
│ + iterations, │
│ + randomSeed ? 937883464, │
│ + raid, │
│ + }: { │
│ + inherit type raid requestId; │
│ + simOptions = { │
│ + inherit iterations randomSeed; │
│ + debugFirstIteration = true; │
│ + }; │
│ + }; │
│ +in │
│ + mkSim │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ nix/lib/simulation.nix ─────────────┐
│ diff --git a/nix/lib/simulation.nix b/nix/li │
│ b/simulation.nix │
│ new file mode 100644 │
│ index 0000000..3722c21 │
│ --- /dev/null │
│ +++ b/nix/lib/simulation.nix │
│ @@ -0,0 +1,16 @@ │
│ +let │
│ + mkSim = { │
│ + requestId ? "raidSimAsync-b01aabae125f3 │
│ 34e", │
│ + type ? "SimTypeIndividual", │
│ + iterations, │
│ + randomSeed ? 937883464, │
│ + raid, │
│ + }: { │
│ + inherit type raid requestId; │
│ + simOptions = { │
│ + inherit iterations randomSeed; │
│ + debugFirstIteration = true; │
│ + }; │
│ + }; │
│ +in │
│ + mkSim │
└──────────────────────────────────────────────┘
┌─ nix/lib/target.nix ───────────────────────────────────────────────────────┐
│ diff --git a/nix/lib/targets.nix b/nix/lib/target.nix │
│ similarity index 96% │
│ rename from nix/lib/targets.nix │
│ rename to nix/lib/target.nix │
│ index d3c2d5c..0eba712 100644 │
│ --- a/nix/lib/targets.nix │
│ +++ b/nix/lib/target.nix │
│ @@ -11,7 +11,7 @@ │
│ inherit id name level damageSpread swingSpeed minBaseDamage; │
│ mobType = "MobType${lib.string.toSentenceCase type}"; │
│ }; │
│ - mobs = { │
│ + target = { │
│ defaultRaidBoss = mkTarget {}; │
│ smallTrash = mkTarget { │
│ level = 90; │
│ @@ -24,4 +24,4 @@ │
│ # todo add raid bosses │
│ }; │
│ in │
│ - targets │
│ + target │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ nix/lib/target.nix ─────────────────┐
│ diff --git a/nix/lib/targets.nix b/nix/lib/t │
│ arget.nix │
│ similarity index 96% │
│ rename from nix/lib/targets.nix │
│ rename to nix/lib/target.nix │
│ index d3c2d5c..0eba712 100644 │
│ --- a/nix/lib/targets.nix │
│ +++ b/nix/lib/target.nix │
│ @@ -11,7 +11,7 @@ │
│ inherit id name level damageSpread swin │
│ gSpeed minBaseDamage; │
│ mobType = "MobType${lib.string.toSenten │
│ ceCase type}"; │
│ }; │
│ - mobs = { │
│ + target = { │
│ defaultRaidBoss = mkTarget {}; │
│ smallTrash = mkTarget { │
│ level = 90; │
│ @@ -24,4 +24,4 @@ │
│ # todo add raid bosses │
│ }; │
│ in │
│ - targets │
│ + target │
└──────────────────────────────────────────────┘
[ BACK TO LOG ]
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET