-
Notifications
You must be signed in to change notification settings - Fork 431
Add flake.nix #4328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SignalWalker
wants to merge
16
commits into
TASEmulators:master
Choose a base branch
from
SignalWalker:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add flake.nix #4328
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2cf2b4e
Nix expr: add flake.nix
SignalWalker 5335d02
Nix expr: add apps output to flake.nix
SignalWalker 77d09ef
Nix expr: update system list
SignalWalker d6493b5
Nix expr: remove answered todo comment
SignalWalker cca130f
Nix expr: add overlay output to `flake.nix`
SignalWalker 216f6c8
Nix expr: use `lib.strings.hasPrefix`
SignalWalker b96005f
Nix expr: use description from README.md
SignalWalker d3bb171
Nix expr: remove formatter
SignalWalker 34ef8f2
Nix expr: fix derivation import in overlay output
SignalWalker fbbb1af
Nix expr: remove redundant apps output from flake.nix
SignalWalker c5a21eb
Nix expr: remove overlay output
SignalWalker 80c58dd
Nix expr: use `lib` instead of `std` in flake.nix
SignalWalker b9c2d44
Nix expr: use `github:NixOS/nixpkgs?ref=24.05` as nixpkgs input in fl…
SignalWalker 05ef888
Nix expr: make `shellHook` an output of `default.nix`, make shells di…
SignalWalker 1ddeff8
Nix expr: only output default devshell and devshells for latest packages
SignalWalker 0524f61
Nix expr: add `isFlake` argument to `shellHook`
SignalWalker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" | ||
| ]; | ||
YoshiRulz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 true 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; | ||
| }; | ||
| } | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait does this work in Flakes?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, when evaluating as part of a flake, that
./.gets interpreted as a nix store path, soBIZHAWKBUILD_HOMEis set to something like/nix/store/1igqk0g3q3bj6zhcfmrgzirzjsqbgpx9-sourceinstead of something like/home/tasbot/bizhawk. That's fine for reading data, but the store is (usually) read-only, so$BIZHAWK_HOMEdoesn't work as-is (I assume).I'm not really sure what the best way to solve this would be (especially in the case of someone doing something like
nix develop github:tasemulators/bizhawk, since that would mean that the source dir only exists in the store).nix developsets environment variables for each of the derivation outputs (ex.$out), which might be useful. They're relative to the directory in which you invokenix develop, though (ex. if you invokenix develop ./.#emuhawk-latestinBizHawk/Dist,$outis set toBizHawk/Dist/outputs/outrather thanBizHawk/outputs/out).Do builds output to
$BIZHAWKBUILD_HOME/output, or do they output to$BIZHAWK_HOME? If it's the latter, does anything expect$BIZHAWKBUILD_HOMEto be writable? If things only expect to be able to write to$BIZHAWK_HOME, we could add anisFlakeparameter to theshellHookfunction and export$BIZHAWK_HOME=$out, if we don't mind that$outisn't guaranteed to be relative to the project root.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it's fine to assume
nix developwill only be called from the repo root, already checked-out.BIZHAWKBUILD_HOMEis used at build-time to locate the repo root (not for the main solution though).BIZHAWK_HOMEis used at run-time, and it was mainly added for NixHawk so I don't think anything expects it to be writable, BUT it can't point to${BizHawk-source}/outputsince that doesn't exist.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some scripts seem to expect to be able to find (and write to)
$BIZHAWKBUILD_HOME/output, ex.:BizHawk/waterbox/waterboxhost/build-debug.sh
Line 8 in caeb811
For
$BIZHAWK_HOME, could we justmkdir -pit in the launch script, since that andPathExtensions.csseem to be the only places it gets used?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do that, but again, it needs to exist and contain the assemblies and other assets. The launch script is essentially
cd $BIZHAWK_HOME; mono ./EmuHawk.exe.No-one is going to be using EmuHawk's dev shell to build WaterboxHost. It can get its own shell when I eventually package it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, if the only thing we care about that uses it is the launch script, and we're assuming that
nix developis only being called from the repo root, then could we just do something like:As-is, if you're in a checked-out repo root, running
Dist/BuildDebug.shinnix developseems to work completely fine and outputs to${repo_root}/output(as in, not$BIZHAWKBUILD_HOME/output).(This would mean, though, that the
printflater on that tells the user where the build scripts are is misleading if you're in a flake, so I'll need to fix that.)