-
Notifications
You must be signed in to change notification settings - Fork 414
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
15
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
15 commits
Select commit
Hold shift + click to select a range
52756cc
Nix expr: add flake.nix
SignalWalker 144e8a7
Nix expr: add apps output to flake.nix
SignalWalker 2593753
Nix expr: update system list
SignalWalker aed4768
Nix expr: remove answered todo comment
SignalWalker 0a196a5
Nix expr: add overlay output to `flake.nix`
SignalWalker ece2064
Nix expr: use `lib.strings.hasPrefix`
SignalWalker f8452a2
Nix expr: use description from README.md
SignalWalker c47195d
Nix expr: remove formatter
SignalWalker 3bd7c86
Nix expr: fix derivation import in overlay output
SignalWalker 5f8bd38
Nix expr: remove redundant apps output from flake.nix
SignalWalker 226b571
Nix expr: remove overlay output
SignalWalker ea7855a
Nix expr: use `lib` instead of `std` in flake.nix
SignalWalker acde1d1
Nix expr: use `github:NixOS/nixpkgs?ref=24.05` as nixpkgs input in fl…
SignalWalker 6be3da2
Nix expr: make `shellHook` an output of `default.nix`, make shells di…
SignalWalker dfbd82e
Nix expr: only output default devshell and devshells for latest packages
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 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_HOME
is set to something like/nix/store/1igqk0g3q3bj6zhcfmrgzirzjsqbgpx9-source
instead of something like/home/tasbot/bizhawk
. That's fine for reading data, but the store is (usually) read-only, so$BIZHAWK_HOME
doesn'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 develop
sets 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-latest
inBizHawk/Dist
,$out
is set toBizHawk/Dist/outputs/out
rather 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_HOME
to be writable? If things only expect to be able to write to$BIZHAWK_HOME
, we could add anisFlake
parameter to theshellHook
function and export$BIZHAWK_HOME=$out
, if we don't mind that$out
isn'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 develop
will only be called from the repo root, already checked-out.BIZHAWKBUILD_HOME
is used at build-time to locate the repo root (not for the main solution though).BIZHAWK_HOME
is 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}/output
since 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 -p
it in the launch script, since that andPathExtensions.cs
seem 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 develop
is 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.sh
innix develop
seems to work completely fine and outputs to${repo_root}/output
(as in, not$BIZHAWKBUILD_HOME/output
).(This would mean, though, that the
printf
later 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.)