Skip to content

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
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 80 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
description = "BizHawk is a multi-system emulator written in C#. BizHawk provides nice features for casual gamers such as full screen, and joypad support in addition to full rerecording and debugging tools for all system cores.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/release-24.05";
};
outputs =
inputs@{ self, nixpkgs, ... }:
with builtins;
let
std = 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 = std.genAttrs systems (
system:
import nixpkgs {
localSystem = builtins.currentSystem or system;
crossSystem = system;
overlays = [ ];
}
);
# because for some reason the standard library doesn't include this (i think?)
startsWith = prefix: st: (substring 0 (stringLength prefix) st) == prefix;
# 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
(std.filterAttrs (name: val: std.isDerivation val) (import ./default.nix { inherit system pkgs; }));
in
{
formatter = mapAttrs (system: pkgs: pkgs.nixfmt-rfc-style) nixpkgsFor;
packages = mapAttrs (
system: pkgs:
(importDefaultDerivationsWith system pkgs)
// {
default = self.packages.${system}.emuhawk-latest-bin;
}
) nixpkgsFor;
devShells = mapAttrs (
system: pkgs:
# ./shell.nix outputs some non-derivation attributes and some extraneous derivations, so we have to filter those out
(std.filterAttrs (
name: val: std.isDerivation val && name != "stdenv" && name != "out" && name != "inputDerivation"
) (import ./shell.nix { inherit system pkgs; }))
// {
default = self.devShells.${system}.emuhawk-latest;
}
) nixpkgsFor;
overlays.default =
final: prev:
# filter derivations to only include `emuhawk` and `discohawk` ones (i.e. excluding `bizhawkAssemblies`)
std.filterAttrs (name: pkg: (startsWith "emuhawk" name) || (startsWith "discohawk" name)) (
# import `default.nix` with the overlayed package set
# (i don't know the circumstances under which `prev` wouldn't have a `system` attribute, but we may as well account for it)
importDefaultDerivationsWith (prev.system or "") prev
);
apps =
let
toApps =
app: pkgs:
# filter packages to only include ones whose name starts with `app`, then map them to app definitions
mapAttrs (name: pkg: {
type = "app";
# this seems to be correct, but I'm not entirely sure
program = "${pkg}/bin/${pkg.name}";
}) (std.filterAttrs (name: val: startsWith app name) pkgs);
in
mapAttrs (
system: pkgs:
(
(toApps "emuhawk" pkgs)
// (toApps "discohawk" pkgs)
// {
default = self.apps.${system}.emuhawk-latest-bin;
}
)
) self.packages;
};
}