fork/slippi-nix

git clone https://git.julia.blue/fork/slippi-nix

Daniel FlanaganMerge pull request #37 from lytedev/update-netplay-beta-146e5cd86

xdg-mime
5.5 KiB162 linesraw
1{
2  inputs = {
3    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
4    git-hooks.url = "github:cachix/git-hooks.nix";
5    git-hooks.inputs.nixpkgs.follows = "nixpkgs";
6    home-manager.url = "github:nix-community/home-manager";
7    home-manager.inputs.nixpkgs.follows = "nixpkgs";
8  };
9
10  nixConfig = {
11    extra-substituters = [
12      "https://slippi-nix.cachix.org"
13    ];
14
15    extra-trusted-public-keys = [
16      "slippi-nix.cachix.org-1:2qnPHiOxTRpzgLEtx6K4kXq/ySDg7zHEJ58J6xNDvBo="
17    ];
18  };
19
20  outputs =
21    {
22      nixpkgs,
23      git-hooks,
24      home-manager,
25      self,
26      ...
27    }:
28    let
29      forSystems = nixpkgs.lib.genAttrs [
30        # "aarch64-darwin"
31        # "x86_64-darwin"
32        # "aarch64-linux"
33        "x86_64-linux"
34      ];
35      pkgsFor = system: (import nixpkgs { inherit system; });
36      genPkgs = func: (forSystems (system: func (pkgsFor system)));
37    in
38    {
39      overlays = {
40        default = self.overlays.slippi;
41
42        slippi = final: prev: {
43          inherit (self.packages.${final.system}.slippi) slippi-netplay slippi-playback slippi-launcher;
44        };
45      };
46
47      packages = genPkgs (pkgs: {
48        default = self.packages.${pkgs.system}.slippi-launcher-desktop;
49        slippi-netplay-beta = pkgs.callPackage ./packages/slippi-netplay-beta.nix { };
50        slippi-netplay = pkgs.callPackage ./packages/slippi-netplay.nix { };
51        slippi-playback = pkgs.callPackage ./packages/slippi-playback.nix { };
52        slippi-launcher = pkgs.callPackage ./packages/slippi-launcher.nix { };
53        slippi-launcher-desktop = pkgs.callPackage ./packages/slippi-launcher-desktop.nix {
54          inherit (pkgs) formats;
55          inherit (self.packages.${pkgs.system})
56            slippi-launcher
57            slippi-netplay
58            slippi-netplay-beta
59            slippi-playback
60            ;
61        };
62      });
63
64      formatter = genPkgs (p: p.nixfmt-rfc-style);
65
66      nixosModules = {
67        default = self.nixosModules.gamecube-controller-adapter;
68        gamecube-controller-adapter = import ./modules/nixos/gamecube-controller-adapter.nix;
69      };
70
71      homeManagerModules = {
72        default = self.homeManagerModules.slippi-launcher;
73        slippi-launcher = ./modules/home-manager;
74      };
75
76      checks = genPkgs (pkgs: {
77        inherit (self.packages.${pkgs.system})
78          slippi-launcher
79          slippi-launcher-desktop
80          slippi-netplay
81          slippi-playback
82          slippi-netplay-beta
83          ;
84        git-hooks = git-hooks.lib.${pkgs.system}.run {
85          src = ./.;
86          hooks = {
87            nixfmt-rfc-style.enable = true;
88          };
89        };
90        home-manager-module-test = pkgs.testers.runNixOSTest {
91          # a simple integration test to ensure that the home manager module
92          # works, boots a host, implying a successful NixOS configuration, and
93          # creates the configuration file referencing the correct packages'
94          # versions
95          name = "home-manager-module-test";
96          nodes.machine =
97            {
98              pkgs,
99              ...
100            }:
101            with pkgs.lib;
102            {
103              imports = [
104                home-manager.nixosModules.home-manager
105                "${nixpkgs}/nixos/tests/common/auto.nix"
106                "${nixpkgs}/nixos/tests/common/x11.nix"
107              ];
108              users.users.daniel = {
109                isNormalUser = true;
110                home = "/home/daniel";
111                createHome = true;
112                extraGroups = [
113                  "wheel"
114                  "users"
115                ];
116              };
117              test-support.displayManager.auto.user = "daniel";
118              home-manager.users.daniel = {
119                imports = with self.homeManagerModules; [
120                  slippi-launcher
121                ];
122                slippi-launcher.enable = true;
123                home = {
124                  username = "daniel";
125                  homeDirectory = "/home/daniel";
126                  stateVersion = "25.05";
127                };
128              };
129              environment.systemPackages = with pkgs; [ jq ];
130              system.stateVersion = "25.05";
131            };
132          testScript =
133            # nodes,
134            { ... }:
135            let
136              hashes = import ./hashes.nix;
137            in
138            ''
139              def as_user(cmd: str):
140                  """
141                  Return a shell command for running a shell command as a specific user.
142                  """
143                  return f"sudo -u daniel -i -- bash -c \"{cmd}\""
144
145              with subtest("ensure slippi launcher settings file references correct versions"):
146                  machine.wait_for_unit("default.target")
147                  machine.succeed("grep ${hashes.netplay.version} '/home/daniel/.config/Slippi Launcher/Settings'")
148                  machine.succeed("grep ${hashes.playback.version} '/home/daniel/.config/Slippi Launcher/Settings'")
149
150              with subtest("ensure netplay appimage version is correct"):
151                  machine.wait_for_unit("default.target")
152                  machine.wait_for_x()
153                  machine.wait_for_file("/home/daniel/.Xauthority")
154                  machine.succeed("xauth merge /home/daniel/.Xauthority")
155                  machine.succeed(as_user("""
156                  "''$(jq -r '.settings.netplayDolphinPath' '/home/daniel/.config/Slippi Launcher/Settings')/Slippi_Online-x86_64.AppImage" --version | grep ${hashes.netplay.version}
157                  """))
158            '';
159        };
160      });
161    };
162}