diff --git a/default.nix b/default.nix index 77ec34e8272..d8efb1a4387 100644 --- a/default.nix +++ b/default.nix @@ -163,8 +163,10 @@ in { || isVersionAtLeast "2.6" value.hawkSourceInfo.version)) ]; latestVersionFrag = lib.head releaseFrags; - combined = pp // asmsFromReleaseArtifacts // releasesEmuHawkInstallables // { - inherit depsForHistoricalRelease populateHawkSourceInfo releaseTagSourceInfos; + combined = let + launchScriptsForLocalBuild = launchScriptsFor emuhawk-local.assemblies true; + in (pp // asmsFromReleaseArtifacts // releasesEmuHawkInstallables // { + inherit depsForHistoricalRelease populateHawkSourceInfo releaseTagSourceInfos launchScriptsForLocalBuild; bizhawkAssemblies = pp.buildAssembliesFor (fillTargetOSDifferences hawkSourceInfoDevBuild); "bizhawkAssemblies-${latestVersionFrag}" = pp.buildAssembliesFor (fillTargetOSDifferences releaseTagSourceInfos."info-${latestVersionFrag}"); @@ -184,8 +186,27 @@ in { IDEs = { kate = [ kate omnisharp-roslyn ]; }; - launchScriptsForLocalBuild = launchScriptsFor emuhawk-local.assemblies true; - }; + shellHook = drv: '' + export BIZHAWKBUILD_HOME='${builtins.toString ./.}' + export BIZHAWK_HOME="$BIZHAWKBUILD_HOME/output/" + ldLibPath='${lib.makeLibraryPath drv.buildInputs}' # for running tests + if [ -z "$LD_LIBRARY_PATH" ]; then + export LD_LIBRARY_PATH="$ldLibPath" + else + export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$ldLibPath" + fi + alias discohawk-monort-local='${launchScriptsForLocalBuild.discohawk}' + alias emuhawk-monort-local='${launchScriptsForLocalBuild.emuhawk}' + case "$-" in *i*) + pfx="$(realpath --relative-to="$PWD" "$BIZHAWKBUILD_HOME")/" + if [ "$pfx" = "./" ]; then pfx=""; fi + printf "%s\n%s\n" \ + "Run ''${pfx}Dist/Build{Debug,Release}.sh to build the solution. You may need to clean up with ''${pfx}Dist/CleanupBuildOutputDirs.sh." \ + "Once built, running {discohawk,emuhawk}-monort-local will pull from ''${pfx}output/* and use Mono from Nixpkgs." + ;; + esac + ''; + }); in combined // lib.listToAttrs (lib.concatLists (builtins.map (f: [ { name = f "latest-bin"; value = combined.${f "${latestVersionFrag}-bin"}; } diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000000..98f71cbeab9 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1717179513, + "narHash": "sha256-vboIEwIQojofItm2xGCdZCzW96U85l9nDW3ifMuAIdM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "63dacb46bf939521bdc93981b4cbb7ecb58427a0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000000..2e71ffd200e --- /dev/null +++ b/flake.nix @@ -0,0 +1,63 @@ +{ + description = "EmuHawk is a multi-system emulator written in C#. As well as quality-of-life features for casual players, it also has recording/playback and debugging tools, making it the first choice for TASers (Tool-Assisted Speedrunners)."; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs?ref=24.05"; + }; + outputs = + inputs@{ self, nixpkgs, ... }: + with builtins; + let + inherit (nixpkgs) lib; + systems = [ + # this is currently the only supported system, according to https://github.com/TASEmulators/BizHawk/issues/1430#issue-396452488 + "x86_64-linux" + ]; + nixpkgsFor = lib.genAttrs systems ( + system: + import nixpkgs { + localSystem = builtins.currentSystem or system; + crossSystem = system; + overlays = [ ]; + } + ); + # import the derivations from default.nix for the given system & package set + importDefaultDerivationsWith = + system: pkgs: + # ./default.nix outputs some non-derivation attributes, so we have to filter those out + (lib.filterAttrs (name: val: lib.isDerivation val) (import ./default.nix { inherit system pkgs; })); + in + { + packages = mapAttrs ( + system: pkgs: + (importDefaultDerivationsWith system pkgs) + // { + default = self.packages.${system}.emuhawk-latest-bin; + } + ) nixpkgsFor; + devShells = mapAttrs ( + system: pkgs: + let + avail = import ./default.nix { inherit system pkgs; }; + mkShellCustom = + drv: + pkgs.mkShell { + packages = with pkgs; [ + git + powershell + ]; + inputsFrom = [ drv ]; + shellHook = avail.shellHook drv; + }; + in + { + bizhawkAssemblies-latest = mkShellCustom avail.bizhawkAssemblies-latest; + discohawk-latest = self.devShells.${system}.bizhawkAssemblies-latest; + emuhawk-latest = self.devShells.${system}.bizhawkAssemblies-latest; + default = pkgs.mkShell { + packages = [ avail.emuhawk.hawkSourceInfo.dotnet-sdk ]; + inputsFrom = [ self.devShells.${system}.emuhawk-latest ]; + }; + } + ) nixpkgsFor; + }; +} diff --git a/shell.nix b/shell.nix index d52f5082a7f..66f980bafb2 100644 --- a/shell.nix +++ b/shell.nix @@ -25,26 +25,7 @@ ++ lib.optionals useVSCode [] #TODO https://devblogs.microsoft.com/dotnet/csharp-dev-kit-now-generally-available/ https://learn.microsoft.com/en-us/training/modules/implement-visual-studio-code-debugging-tools/ ; inputsFrom = [ drv ]; - shellHook = '' - export BIZHAWKBUILD_HOME='${builtins.toString ./.}' - export BIZHAWK_HOME="$BIZHAWKBUILD_HOME/output/" - ldLibPath='${lib.makeLibraryPath drv.buildInputs}' # for running tests - if [ -z "$LD_LIBRARY_PATH" ]; then - export LD_LIBRARY_PATH="$ldLibPath" - else - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$ldLibPath" - fi - alias discohawk-monort-local='${avail.launchScriptsForLocalBuild.discohawk}' - alias emuhawk-monort-local='${avail.launchScriptsForLocalBuild.emuhawk}' - case "$-" in *i*) - pfx="$(realpath --relative-to="$PWD" "$BIZHAWKBUILD_HOME")/" - if [ "$pfx" = "./" ]; then pfx=""; fi - printf "%s\n%s\n" \ - "Run ''${pfx}Dist/Build{Debug,Release}.sh to build the solution. You may need to clean up with ''${pfx}Dist/CleanupBuildOutputDirs.sh." \ - "Once built, running {discohawk,emuhawk}-monort-local will pull from ''${pfx}output/* and use Mono from Nixpkgs." - ;; - esac - ''; + shellHook = avail.shellHook drv; }; shells = lib.pipe avail [ (lib.mapAttrs (name: drv: if lib.hasPrefix "bizhawkAssemblies-" name then drv else drv.assemblies or null))