-
Notifications
You must be signed in to change notification settings - Fork 26
/
flake.nix
69 lines (66 loc) · 2.59 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{
description = "AniLibria.Qt cross platform desktop client";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixGL.url = "github:nix-community/nixGL";
nixGL.inputs.nixpkgs.follows = "nixpkgs";
nixGL.inputs.flake-utils.follows = "flake-utils";
flake-utils.url = "github:numtide/flake-utils";
flake-compat.url = "github:edolstra/flake-compat";
flake-compat.flake = false;
};
outputs = inputs @{ self, nixpkgs, nixGL, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (nixGL.overlays.default) ];
config = { allowUnfree = true; }; # needed for nvidia driver
};
wrapWithNixGL = anilibria-winmaclinux: nixGl: { nixGLCMD ? pkgs.lib.getExe nixGl }:
let
wrapper = pkgs.writeShellApplication
{
name = "AniLibria";
runtimeInputs = [ anilibria-winmaclinux nixGl ];
text = ''
${nixGLCMD} ${pkgs.lib.getExe anilibria-winmaclinux} "$@"
'';
};
in
pkgs.stdenvNoCC.mkDerivation {
pname = "anilibria-winmaclinux" + nixGl.name;
version = anilibria-winmaclinux.version;
inherit (anilibria-winmaclinux) meta;
buildCommand = ''
mkdir -p $out/bin
ln -s ${anilibria-winmaclinux}/share $out/share
cp ${pkgs.lib.getExe wrapper} $out/bin/${pkgs.lib.lists.last (pkgs.lib.strings.split "/" (pkgs.lib.getExe anilibria-winmaclinux))}
'';
};
genPkgs = pkgs: pkg:
rec {
default = auto;
nixos = pkg;
auto = wrapWithNixGL pkg pkgs.nixgl.auto.nixGLDefault { nixGLCMD = "nixGL"; };
nvidia = wrapWithNixGL pkg pkgs.nixgl.auto.nixGLNvidia { };
nvidia-hybrid = wrapWithNixGL pkg pkgs.nixgl.auto.nixGLNvidiaBumblebee { };
intel = wrapWithNixGL pkg pkgs.nixgl.nixGLIntel { };
amd = intel;
};
in
rec {
packages = (genPkgs pkgs
(
pkgs.anilibria-winmaclinux.overrideAttrs (old: rec {
src = ./.;
setSourceRoot = "sourceRoot=$(echo *source*/src)";
})
));
devShells.default = pkgs.mkShell {
nativeBuildInputs = packages.nixos.nativeBuildInputs;
buildInputs = packages.nixos.buildInputs;
};
});
}