Compare commits
No commits in common. "223fb72217b97ed13248713b5825b234023eed83" and "d43f5ce6761e609de875eeb2f36a12ef339f98d6" have entirely different histories.
223fb72217
...
d43f5ce676
2 changed files with 145 additions and 105 deletions
57
flake.lock
generated
57
flake.lock
generated
|
@ -1,60 +1,35 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"flake-parts": {
|
"flake-utils": {
|
||||||
"inputs": {
|
|
||||||
"nixpkgs-lib": "nixpkgs-lib"
|
|
||||||
},
|
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1704982712,
|
"lastModified": 1659877975,
|
||||||
"narHash": "sha256-2Ptt+9h8dczgle2Oo6z5ni5rt/uLMG47UFTR1ry/wgg=",
|
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||||
"owner": "hercules-ci",
|
"owner": "numtide",
|
||||||
"repo": "flake-parts",
|
"repo": "flake-utils",
|
||||||
"rev": "07f6395285469419cf9d078f59b5b49993198c00",
|
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "hercules-ci",
|
"id": "flake-utils",
|
||||||
"repo": "flake-parts",
|
"type": "indirect"
|
||||||
"type": "github"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1705133751,
|
"lastModified": 1663850217,
|
||||||
"narHash": "sha256-rCIsyE80jgiOU78gCWN3A0wE0tR2GI5nH6MlS+HaaSQ=",
|
"narHash": "sha256-tp9nXo1/IdN/xN9m06ryy0QUAEfoN6K56ObM/1QTAjc=",
|
||||||
"owner": "NixOS",
|
"path": "/nix/store/if56vv9237zafkzgzcdkqxf2lmp86myq-source",
|
||||||
"repo": "nixpkgs",
|
"rev": "ae1dc133ea5f1538d035af41e5ddbc2ebcb67b90",
|
||||||
"rev": "9b19f5e77dd906cb52dade0b7bd280339d2a1f3d",
|
"type": "path"
|
||||||
"type": "github"
|
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "NixOS",
|
"id": "nixpkgs",
|
||||||
"ref": "nixos-unstable",
|
"type": "indirect"
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs-lib": {
|
|
||||||
"locked": {
|
|
||||||
"dir": "lib",
|
|
||||||
"lastModified": 1703961334,
|
|
||||||
"narHash": "sha256-M1mV/Cq+pgjk0rt6VxoyyD+O8cOUiai8t9Q6Yyq4noY=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "b0d36bd0a420ecee3bc916c91886caca87c894e9",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"dir": "lib",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"ref": "nixos-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-parts": "flake-parts",
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
193
flake.nix
193
flake.nix
|
@ -1,82 +1,147 @@
|
||||||
{
|
{
|
||||||
description = "NixOS module for Shunshine";
|
description = "A very basic flake";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs = { };
|
||||||
flake-parts = {
|
flake-utils = { };
|
||||||
url = "github:hercules-ci/flake-parts";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-parts, ... }@inputs:
|
outputs = { self, nixpkgs, flake-utils }:
|
||||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
flake-utils.lib.eachSystem [ "x86_64-linux" ]
|
||||||
systems = [ "x86_64-linux" ];
|
(system:
|
||||||
perSystem = { self', pkgs, lib, ... }: {
|
let
|
||||||
formatter = pkgs.nixpkgs-fmt;
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
lib = nixpkgs.lib;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
formatter = pkgs.nixpkgs-fmt;
|
||||||
|
packages = {
|
||||||
|
sunshine = pkgs.stdenv.mkDerivation {
|
||||||
|
pname = "sunshine";
|
||||||
|
version = "0.14.1";
|
||||||
|
|
||||||
devShells.default = with pkgs; mkShell { };
|
src = pkgs.fetchFromGitHub {
|
||||||
|
owner = "LizardByte";
|
||||||
};
|
repo = "Sunshine";
|
||||||
flake = {
|
rev = "6000b85b1a4ec574d93fbc7545f5bf48f3d5aaa7";
|
||||||
nixosModules.sunshine = { pkgs, config, lib, ... }:
|
sha256 = "SB2DAOYf2izIwwRWEw2wt5L5oCDbb6YOqXw/z/PD1pQ=";
|
||||||
with lib;
|
fetchSubmodules = true;
|
||||||
let
|
|
||||||
inherit (pkgs) sunshine;
|
|
||||||
cfg = config.services.sunshine;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options.services.sunshine = {
|
|
||||||
enable = mkEnableOption "sunshine";
|
|
||||||
|
|
||||||
user = mkOption {
|
|
||||||
description = "The user using sunshine";
|
|
||||||
type = types.str;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
openFirewall = mkOption {
|
buildInputs = with pkgs; [
|
||||||
description = "Open the necessary ports for sunshine";
|
avahi
|
||||||
type = types.bool;
|
(boost.override { enableStatic = true; })
|
||||||
default = false;
|
ffmpeg
|
||||||
};
|
libevdev
|
||||||
};
|
libpulseaudio
|
||||||
|
xorg.libX11
|
||||||
|
xorg.libxcb
|
||||||
|
xorg.libXfixes
|
||||||
|
xorg.libXrandr
|
||||||
|
xorg.libXtst
|
||||||
|
openssl
|
||||||
|
libopus
|
||||||
|
udev
|
||||||
|
libdrm
|
||||||
|
valgrind.dev
|
||||||
|
wayland
|
||||||
|
libffi
|
||||||
|
icu
|
||||||
|
];
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
hardeningDisable = [ "format" ];
|
||||||
environment.systemPackages = [ sunshine ];
|
|
||||||
|
|
||||||
hardware.uinput.enable = true;
|
nativeBuildInputs = with pkgs; [
|
||||||
|
cmake
|
||||||
|
pkgconf
|
||||||
|
makeWrapper
|
||||||
|
];
|
||||||
|
|
||||||
users.extraUsers.${cfg.user}.extraGroups = [ "uinput" "video" ];
|
cmakeFlags = [
|
||||||
security.wrappers.sunshine = {
|
"-DCMAKE_INSTALL_PREFIX=${placeholder "out"}"
|
||||||
owner = "root";
|
"-DSUNSHINE_ASSETS_DIR=share/sunshine"
|
||||||
group = "root";
|
"-DSUNSHINE_CONFIG_DIR=share/sunshine"
|
||||||
capabilities = "cap_sys_admin+p";
|
];
|
||||||
source = "${sunshine}/bin/sunshine";
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.user.services.sunshine = {
|
# patches = [ ./001-cmake-find-evdev.patch ];
|
||||||
description = "Sunshine is a Gamestream host for Moonlight";
|
patches = [ ./sunshine.patch ];
|
||||||
|
|
||||||
serviceConfig.ExecStart = "${config.security.wrapperDir}/sunshine";
|
preConfigure = ''
|
||||||
|
substituteInPlace CMakeLists.txt \
|
||||||
|
--replace "/usr/include/libevdev-1.0" "${pkgs.libevdev}/include/libevdev-1.0" \
|
||||||
|
'';
|
||||||
|
|
||||||
wantedBy = [ "graphical-session.target" ];
|
postInstall = ''
|
||||||
};
|
rm -r $out/lib/systemd
|
||||||
|
wrapProgram $out/bin/sunshine --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath (with pkgs; [ avahi mesa libGL ])}"
|
||||||
networking.firewall = mkIf cfg.openFirewall {
|
'';
|
||||||
allowedTCPPorts = [
|
|
||||||
48010
|
|
||||||
];
|
|
||||||
|
|
||||||
allowedTCPPortRanges = [
|
|
||||||
{ from = 47984; to = 47990; }
|
|
||||||
];
|
|
||||||
|
|
||||||
allowedUDPPortRanges = [
|
|
||||||
{ from = 47998; to = 48000; }
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
packages.default = self.packages.${system}.sunshine;
|
||||||
|
|
||||||
|
devShells.default = with pkgs; mkShell {
|
||||||
|
nativeBuildInputs = [ nix-prefetch-scripts nix-prefetch-github cmake-language-server ];
|
||||||
|
inputsFrom = [ self.packages.${system}.sunshine ];
|
||||||
|
};
|
||||||
|
|
||||||
|
}) // {
|
||||||
|
nixosModules.sunshine = { pkgs, config, lib, ... }:
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
cfg = config.services.sunshine;
|
||||||
|
sunshine = self.packages.${pkgs.system}.sunshine;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.services.sunshine = {
|
||||||
|
enable = mkEnableOption "sunshine";
|
||||||
|
|
||||||
|
user = mkOption {
|
||||||
|
description = "The user using sunshine";
|
||||||
|
type = types.str;
|
||||||
|
};
|
||||||
|
|
||||||
|
openFirewall = mkOption {
|
||||||
|
description = "Open the necessary ports for sunshine";
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
environment.systemPackages = [ sunshine ];
|
||||||
|
|
||||||
|
hardware.uinput.enable = true;
|
||||||
|
|
||||||
|
users.extraUsers.${cfg.user}.extraGroups = [ "uinput" "video" ];
|
||||||
|
security.wrappers.sunshine = {
|
||||||
|
owner = "root";
|
||||||
|
group = "root";
|
||||||
|
capabilities = "cap_sys_admin+p";
|
||||||
|
source = "${sunshine}/bin/sunshine";
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.user.services.sunshine = {
|
||||||
|
description = "Sunshine is a Gamestream host for Moonlight";
|
||||||
|
|
||||||
|
serviceConfig.ExecStart = "${config.security.wrapperDir}/sunshine";
|
||||||
|
|
||||||
|
wantedBy = [ "graphical-session.target" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
networking.firewall = mkIf cfg.openFirewall {
|
||||||
|
allowedTCPPorts = [
|
||||||
|
48010
|
||||||
|
];
|
||||||
|
|
||||||
|
allowedTCPPortRanges = [
|
||||||
|
{ from = 47984; to = 47990; }
|
||||||
|
];
|
||||||
|
|
||||||
|
allowedUDPPortRanges = [
|
||||||
|
{ from = 47998; to = 48000; }
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue