diff --git a/flake.lock b/flake.lock index 0410993b3..093a5d86c 100644 --- a/flake.lock +++ b/flake.lock @@ -1,61 +1,5 @@ { "nodes": { - "cachix": { - "inputs": { - "devenv": [ - "devenv" - ], - "flake-compat": [ - "devenv" - ], - "git-hooks": [ - "devenv", - "git-hooks" - ], - "nixpkgs": [ - "devenv", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1748883665, - "narHash": "sha256-R0W7uAg+BLoHjMRMQ8+oiSbTq8nkGz5RDpQ+ZfxxP3A=", - "owner": "cachix", - "repo": "cachix", - "rev": "f707778d902af4d62d8dd92c269f8e70de09acbe", - "type": "github" - }, - "original": { - "owner": "cachix", - "ref": "latest", - "repo": "cachix", - "type": "github" - } - }, - "devenv": { - "inputs": { - "cachix": "cachix", - "flake-compat": "flake-compat", - "git-hooks": "git-hooks", - "nix": "nix", - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1757003908, - "narHash": "sha256-Op3cnPTav+ObcL4R4BGuWHEFxW6YS2A0aE3Av6sZN2g=", - "owner": "cachix", - "repo": "devenv", - "rev": "ac8ebf17828c0e7d9be0270d359123fffcc6f066", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "devenv", - "type": "github" - } - }, "fenix": { "inputs": { "nixpkgs": [ @@ -77,217 +21,21 @@ "type": "github" } }, - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1747046372, - "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, "flake-parts": { - "inputs": { - "nixpkgs-lib": [ - "devenv", - "nix", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1733312601, - "narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "flake-parts_2": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1756770412, - "narHash": "sha256-+uWLQZccFHwqpGqr2Yt5VsW/PbeJVTn9Dk6SHWhNRPw=", + "lastModified": 1762980239, + "narHash": "sha256-8oNVE8TrD19ulHinjaqONf9QWCKK+w4url56cdStMpM=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "4524271976b625a4a605beefd893f270620fd751", - "type": "github" - }, - "original": { - "id": "flake-parts", - "type": "indirect" - } - }, - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "git-hooks": { - "inputs": { - "flake-compat": [ - "devenv", - "flake-compat" - ], - "gitignore": "gitignore", - "nixpkgs": [ - "devenv", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1750779888, - "narHash": "sha256-wibppH3g/E2lxU43ZQHC5yA/7kIKLGxVEnsnVK1BtRg=", - "owner": "cachix", - "repo": "git-hooks.nix", - "rev": "16ec914f6fb6f599ce988427d9d94efddf25fe6d", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "git-hooks.nix", - "type": "github" - } - }, - "gitignore": { - "inputs": { - "nixpkgs": [ - "devenv", - "git-hooks", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1709087332, - "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "rev": "52a2caecc898d0b46b2b905f058ccc5081f842da", "type": "github" }, "original": { "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, - "mk-shell-bin": { - "locked": { - "lastModified": 1677004959, - "narHash": "sha256-/uEkr1UkJrh11vD02aqufCxtbF5YnhRTIKlx5kyvf+I=", - "owner": "rrbutani", - "repo": "nix-mk-shell-bin", - "rev": "ff5d8bd4d68a347be5042e2f16caee391cd75887", - "type": "github" - }, - "original": { - "owner": "rrbutani", - "repo": "nix-mk-shell-bin", - "type": "github" - } - }, - "nix": { - "inputs": { - "flake-compat": [ - "devenv", - "flake-compat" - ], - "flake-parts": "flake-parts", - "git-hooks-nix": [ - "devenv", - "git-hooks" - ], - "nixpkgs": [ - "devenv", - "nixpkgs" - ], - "nixpkgs-23-11": [ - "devenv" - ], - "nixpkgs-regression": [ - "devenv" - ] - }, - "locked": { - "lastModified": 1755029779, - "narHash": "sha256-3+GHIYGg4U9XKUN4rg473frIVNn8YD06bjwxKS1IPrU=", - "owner": "cachix", - "repo": "nix", - "rev": "b0972b0eee6726081d10b1199f54de6d2917f861", - "type": "github" - }, - "original": { - "owner": "cachix", - "ref": "devenv-2.30", - "repo": "nix", - "type": "github" - } - }, - "nix2container": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1752002763, - "narHash": "sha256-JYAkdZvpdSx9GUoHPArctYMypSONob4DYKRkOubUWtY=", - "owner": "nlewo", - "repo": "nix2container", - "rev": "4f2437f6a1844b843b380d483087ae6d461240ee", - "type": "github" - }, - "original": { - "owner": "nlewo", - "repo": "nix2container", - "type": "github" - } - }, - "nixgl": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1752054764, - "narHash": "sha256-Ob/HuUhANoDs+nvYqyTKrkcPXf4ZgXoqMTQoCK0RFgQ=", - "owner": "guibou", - "repo": "nixGL", - "rev": "a8e1ce7d49a149ed70df676785b07f63288f53c5", - "type": "github" - }, - "original": { - "owner": "guibou", - "repo": "nixGL", + "repo": "flake-parts", "type": "github" } }, @@ -309,11 +57,11 @@ }, "nixpkgs-lib": { "locked": { - "lastModified": 1754788789, - "narHash": "sha256-x2rJ+Ovzq0sCMpgfgGaaqgBSwY+LST+WbZ6TytnT9Rk=", + "lastModified": 1761765539, + "narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=", "owner": "nix-community", "repo": "nixpkgs.lib", - "rev": "a73b9c743612e4244d865a2fdee11865283c04e6", + "rev": "719359f4562934ae99f5443f20aa06c2ffff91fc", "type": "github" }, "original": { @@ -324,12 +72,8 @@ }, "root": { "inputs": { - "devenv": "devenv", "fenix": "fenix", - "flake-parts": "flake-parts_2", - "mk-shell-bin": "mk-shell-bin", - "nix2container": "nix2container", - "nixgl": "nixgl", + "flake-parts": "flake-parts", "nixpkgs": "nixpkgs" } }, @@ -349,21 +93,6 @@ "repo": "rust-analyzer", "type": "github" } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index d58fdb79b..8de560edd 100644 --- a/flake.nix +++ b/flake.nix @@ -3,154 +3,72 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - devenv = { - url = "github:cachix/devenv"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - nix2container = { - url = "github:nlewo/nix2container"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - mk-shell-bin.url = "github:rrbutani/nix-mk-shell-bin"; - nixgl = { - url = "github:guibou/nixGL"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + flake-parts.url = "github:hercules-ci/flake-parts"; fenix = { url = "github:nix-community/fenix"; inputs.nixpkgs.follows = "nixpkgs"; }; }; - nixConfig = { - extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="; - extra-substituters = "https://devenv.cachix.org"; - }; + outputs = inputs@{ self, nixpkgs, flake-parts, fenix, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; - outputs = inputs @ { - self, - flake-parts, - nixgl, - ... - }: - flake-parts.lib.mkFlake {inherit inputs;} { - imports = [ - inputs.devenv.flakeModule - ]; - systems = ["x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"]; + perSystem = { system, lib, ... }: + let + pkgs = import nixpkgs { inherit system; }; - perSystem = { - config, - self', - inputs', - pkgs, - system, - lib, - ... - }: { - # Per-system attributes can be defined here. The self' and inputs' - # module parameters provide easy access to attributes of the same - # system. - - # Equivalent to inputs'.nixpkgs.legacyPackages.hello; - # packages.default = pkgs.hello; - _module.args.pkgs = import self.inputs.nixpkgs { - inherit system; - overlays = [nixgl.overlay]; - }; - - devenv.shells.default = let - fenixpkgs = inputs'.fenix.packages; rust_toolchain = lib.importTOML ./rust-toolchain.toml; + fenixPkgs = fenix.packages.${system}; + + rustToolchainSet = fenixPkgs.fromToolchainName { + name = rust_toolchain.toolchain.channel; + sha256 = "sha256-+9FmLhAOezBZCOziO0Qct1NOrfpjNsXxc/8I0c7BdKE="; + }; in { - name = "slimevr"; - imports = [ - # This is just like the imports in devenv.nix. - # See https://devenv.sh/guides/using-with-flake-parts/#import-a-devenv-module - # ./devenv-foo.nix - ]; + devShells.default = pkgs.mkShell { + name = "slimevr"; - # https://devenv.sh/reference/options/ - packages = - (with pkgs; [ - pkgs.nixgl.nixGLIntel - cacert - ]) - ++ lib.optionals pkgs.stdenv.isLinux (with pkgs; [ - atk - cairo - dbus - dbus.lib - dprint - gdk-pixbuf - glib.out - glib-networking - gobject-introspection - gtk3 - harfbuzz - libffi - libsoup_3 - openssl.dev - pango - pkg-config - treefmt - webkitgtk_4_1 - zlib - gst_all_1.gstreamer - gst_all_1.gst-plugins-base - gst_all_1.gst-plugins-good - gst_all_1.gst-plugins-bad - librsvg - freetype - expat - libayatana-appindicator - libusb1 - ]) - ++ lib.optionals pkgs.stdenv.isDarwin [ - pkgs.darwin.apple_sdk.frameworks.Security - ]; + buildInputs = + (with pkgs; [ + cacert + ]) ++ lib.optionals pkgs.stdenv.isLinux (with pkgs; [ + atk cairo dbus dbus.lib dprint gdk-pixbuf glib.out glib-networking + gobject-introspection gtk3 harfbuzz libffi libsoup_3 openssl.dev pango + pkg-config treefmt webkitgtk_4_1 zlib + gst_all_1.gstreamer gst_all_1.gst-plugins-base + gst_all_1.gst-plugins-good gst_all_1.gst-plugins-bad + librsvg freetype expat libayatana-appindicator udev libusb1 + ]) ++ lib.optionals pkgs.stdenv.isDarwin [ + pkgs.darwin.apple_sdk.frameworks.Security + ] ++ [ + pkgs.jdk17 + pkgs.kotlin + rustToolchainSet.rustc + rustToolchainSet.cargo + rustToolchainSet.rustfmt + ]; - languages.java = { - enable = true; - gradle.enable = true; - jdk.package = pkgs.jdk17; - }; - languages.kotlin.enable = true; + nativeBuildInputs = with pkgs; [ pnpm nodejs_22 gradle ]; - languages.javascript = { - enable = true; - corepack.enable = true; - pnpm.enable = true; - npm.enable = true; - }; - - languages.rust = { - enable = true; - toolchain = fenixpkgs.fromToolchainName { - name = rust_toolchain.toolchain.channel; - sha256 = "sha256-+9FmLhAOezBZCOziO0Qct1NOrfpjNsXxc/8I0c7BdKE="; - }; - components = rust_toolchain.toolchain.components; - }; - - env = { + RUST_BACKTRACE = 1; GIO_EXTRA_MODULES = "${pkgs.glib-networking}/lib/gio/modules:${pkgs.dconf.lib}/lib/gio/modules"; - }; - enterShell = with pkgs; '' - # Export a LD_LIBRARY_PATH without libudev-zero as libgudev not likey - export SLIMEVR_RUST_LD_LIBRARY_PATH="$LD_LIBRARY_PATH" - export LD_LIBRARY_PATH="${libudev-zero}/lib:${libayatana-appindicator}/lib:$LD_LIBRARY_PATH" - # GStreamer plugins won't be found without this - export GST_PLUGIN_SYSTEM_PATH_1_0="${pkgs.gst_all_1.gstreamer.out}/lib/gstreamer-1.0:${pkgs.gst_all_1.gst-plugins-base}/lib/gstreamer-1.0:${pkgs.gst_all_1.gst-plugins-good}/lib/gstreamer-1.0:${pkgs.gst_all_1.gst-plugins-bad}/lib/gstreamer-1.0" - ''; + shellHook = '' + export SLIMEVR_RUST_LD_LIBRARY_PATH="$LD_LIBRARY_PATH" + export LD_LIBRARY_PATH="${pkgs.udev}/lib:${pkgs.libayatana-appindicator}/lib:$LD_LIBRARY_PATH" + export GST_PLUGIN_SYSTEM_PATH_1_0="${pkgs.gst_all_1.gstreamer.out}/lib/gstreamer-1.0:${pkgs.gst_all_1.gst-plugins-base}/lib/gstreamer-1.0:${pkgs.gst_all_1.gst-plugins-good}/lib/gstreamer-1.0:${pkgs.gst_all_1.gst-plugins-bad}/lib/gstreamer-1.0" + + # Force linker and pkg-config to use udev from nixpkgs so libgudev/hidapi + # resolve against the correct libudev implementation at link time. + export PKG_CONFIG_PATH="${pkgs.udev}/lib/pkgconfig:${pkgs.glib}/lib/pkgconfig:$PKG_CONFIG_PATH" + export LIBRARY_PATH="${pkgs.udev}/lib:$LIBRARY_PATH" + export LD_RUN_PATH="${pkgs.udev}/lib:$LD_RUN_PATH" + export NIX_LDFLAGS="-L${pkgs.udev}/lib -ludev $NIX_LDFLAGS" + export LDFLAGS="-L${pkgs.udev}/lib -Wl,-rpath,${pkgs.udev}/lib -ludev $LDFLAGS" + ''; + }; }; - }; - flake = { - # The usual flake attributes can be defined here, including system- - # agnostic ones like nixosModule and system-enumerating ones, although - # those are more easily expressed in perSystem. - }; }; } diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 6d642dc59..000000000 --- a/shell.nix +++ /dev/null @@ -1,2 +0,0 @@ -# Just uses the flake. For the nix-env addon (which is kind of dead) users, I use the direnv addon. -(builtins.getFlake ("git+file://" + toString ./.)).devShells.${builtins.currentSystem}.default