diff --git a/flake.lock b/flake.lock index 79fef6d..6d6f074 100644 --- a/flake.lock +++ b/flake.lock @@ -193,6 +193,21 @@ "type": "github" } }, + "flake-utils_4": { + "locked": { + "lastModified": 1623875721, + "narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "f7e004a55b120c02ecb6219596820fcd32ca8772", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -499,6 +514,7 @@ "pure": "pure", "radialstatus": "radialstatus", "rolecolor-everywhere": "rolecolor-everywhere", + "rust-overlay": "rust-overlay", "spotify-adblock": "spotify-adblock", "theme-toggler": "theme-toggler", "tokyonight": "tokyonight", @@ -512,6 +528,27 @@ "zsh-history-substring-search": "zsh-history-substring-search" } }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils_4", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1637115307, + "narHash": "sha256-G+RKZeE1yLrnq+ExHF+HnSJsT+QJWebGhssgZHz3B00=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "8a2e5fa870df3d34667d28fb3383d19516d182e4", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, "spotify-adblock": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index bcee73f..4b8967c 100644 --- a/flake.nix +++ b/flake.nix @@ -28,6 +28,10 @@ tree-sitter-glimmer = { url = "github:alexlafroscia/tree-sitter-glimmer"; flake = false; }; tree-sitter-jsonc = { url = "gitlab:WhyNotHugo/tree-sitter-jsonc"; flake = false; }; + # shells + rust-overlay.url = "github:oxalica/rust-overlay"; + rust-overlay.inputs.nixpkgs.follows = "nixpkgs"; + # powercord plugins/themes better-status-indicators = { url = "github:griefmodz/better-status-indicators"; flake = false; }; channel-typing = { url = "github:powercord-community/channel-typing"; flake = false; }; @@ -81,6 +85,7 @@ nixosConfigurations."blossom" = mkSystem "blossom" "x86_64-linux" true; nixosConfigurations."fondue" = mkSystem "fondue" "x86_64-linux" false; + devShells.x86_64-linux = pkgs.callPackage ./shells { inherit inputs; }; packages.x86_64-linux = pkgs.me; }; } diff --git a/modules/system/base.nix b/modules/system/base.nix index 394ebf5..cdcc838 100644 --- a/modules/system/base.nix +++ b/modules/system/base.nix @@ -20,6 +20,7 @@ }; nix.registry.config.flake = inputs.self; nix.registry.nixpkgs.flake = inputs.nixpkgs; + nix.registry.shells.flake = inputs.self; home-manager = { useGlobalPkgs = true; diff --git a/shells/cs/default.nix b/shells/cs/default.nix new file mode 100644 index 0000000..8f7e42a --- /dev/null +++ b/shells/cs/default.nix @@ -0,0 +1,14 @@ +{ + callPackage, + lib, + mkShell, + dotnetCorePackages +}: +mkShell { + nativeBuildInputs = [ (with dotnetCorePackages; combinePackages [ sdk_6_0 runtime_6_0 ]) ]; + DOTNET_CLI_TELEMETRY_OPTOUT = 1; + + passthru = { + osu = callPackage ./osu.nix {}; + }; +} diff --git a/shells/cs/osu.nix b/shells/cs/osu.nix new file mode 100644 index 0000000..b85070b --- /dev/null +++ b/shells/cs/osu.nix @@ -0,0 +1,80 @@ +# Flake for development on https://github.com/ppy/osu +{ + lib, + mkShell, + writeScript, + stdenv, + stdenvNoCC, + + dotnetCorePackages, + + alsa-lib, + ffmpeg_4, + icu, + lltng-ust, + numactl, + openssl, + SDL2 +}: +let + baseBuild = "-f net5.0 -v minimal /property:Version=$OSU_VERSION osu.Desktop -- $@"; + + deps = [ + alsa-lib ffmpeg_4 icu lttng-ust numactl openssl SDL2 + ]; + + fixSdl = writeScript "osu-fixsdl" '' + ln -sft osu.Desktop/bin/Debug/net5.0/linux-x64/ ${SDL2}/lib/libSDL2${stdenv.hostPlatform.extensions.sharedLibrary} + ln -sft osu.Desktop/bin/Release/net5.0/linux-x64/ ${SDL2}/lib/libSDL2${stdenv.hostPlatform.extensions.sharedLibrary} + ''; + buildScript = writeScript "osu-build" '' + rm -f osu.Desktop/bin/Debug/net5.0/linux-x64/libSDL2.so + dotnet build -c Debug -r linux-x64 ${baseBuild} && ${fixSdl} + ''; + buildReleaseScript = writeScript "osu-build-rel" '' + rm -f osu.Desktop/bin/Release/net5.0/linux-x64/libSDL2.so + dotnet build -c Release -r linux-x64 ${baseBuild} && ${fixSdl} + ''; + publishScript = writeScript "osu-publish" '' + rm -f osu.Desktop/bin/Release/net5.0/linux-x64/libSDL2.so + dotnet publish -c Release -r linux-x64 --self-contained false ${baseBuild} && ${fixSdl} + ''; + publishWinScript = writeScript "osu-publish-win" '' + dotnet publish -c Release -r win-x64 --self-contained false -o build-win ${baseBuild} + ''; + runScript = writeScript "osu-run" '' + ${buildScript} && dotnet run --no-build -c Debug -f net5.0 -r linux-x64 -p osu.Desktop -v minimal -- $@ + ''; + runReleaseScript = writeScript "osu-run-rel" '' + ${buildReleaseScript} && dotnet run --no-build -c Release -f net5.0 -r linux-x64 -p osu.Desktop -v minimal -- $@ + ''; + + scripts = stdenvNoCC.mkDerivation { + pname = "osu-scripts"; + version = "1.0.0"; + dontUnpack = true; + installPhase = '' + mkdir $out + cp ${fixSdl} $out/osu-fixsdl + cp ${buildScript} $out/osu-build + cp ${buildReleaseScript} $out/osu-build-rel + cp ${publishScript} $out/osu-publish + cp ${publishWinScript} $out/osu-publish-win + cp ${runScript} $out/osu-run + cp ${runReleaseScript} $out/osu-run-rel + ''; + }; +in mkShell { + nativeBuildInputs = [ + icu + + (with dotnetCorePackages; combinePackages [ sdk_5_0 runtime_5_0 ]) + ]; + + DOTNET_CLI_TELEMETRY_OPTOUT = 1; + DRI_PRIME = 1; + LD_LIBRARY_PATH = lib.makeLibraryPath deps; + shellHook = '' + export PATH="${scripts}:$PATH" + ''; +} diff --git a/shells/default.nix b/shells/default.nix new file mode 100644 index 0000000..d4a08da --- /dev/null +++ b/shells/default.nix @@ -0,0 +1,7 @@ +{ callPackage, inputs }: { + cs = callPackage ./cs {}; + flutter = callPackage ./flutter {}; + js = callPackage ./js {}; + php = callPackage ./php {}; + rust = callPackage ./rust { inherit inputs; }; +} diff --git a/shells/flutter/default.nix b/shells/flutter/default.nix new file mode 100644 index 0000000..0f49c4d --- /dev/null +++ b/shells/flutter/default.nix @@ -0,0 +1,53 @@ +{ + lib, + mkShell, + + flutter, + clang, + cmake, + ninja, + pkg-config, + + atk, + cairo, + gdk-pixbuf, + glib, + gtk3, + harfbuzz, + libGL, + pango, + wayland, + xorg, +}: +let + makeIncludePath = lib.makeSearchPathOutput "include" "include"; + + includePath = makeIncludePath [ + xorg.xorgproto + xorg.libX11.dev + ]; +in mkShell { + nativeBuildInputs = [ + flutter + clang + cmake + ninja + pkg-config + ]; + + C_INCLUDE_PATH = includePath; + CPLUS_INCLUDE_PATH = includePath; + + LD_LIBRARY_PATH = lib.makeLibraryPath "/lib" [ + atk + cairo + gdk-pixbuf + glib + gtk3 + harfbuzz + libGL + pango + wayland + xorg.libX11 + ]; +} diff --git a/shells/js/default.nix b/shells/js/default.nix new file mode 100644 index 0000000..12fac7d --- /dev/null +++ b/shells/js/default.nix @@ -0,0 +1,19 @@ +{ + mkShell, + + nodejs-16_x, + nodePackages, + watchman +}: +mkShell { + buildInputs = [ + nodejs-16_x + watchman + + nodePackages.pnpm + ]; + + shellHook = '' + export PATH="$(readlink -f ./node_modules/.bin):$PATH" + ''; +} diff --git a/shells/php/default.nix b/shells/php/default.nix new file mode 100644 index 0000000..f0777dd --- /dev/null +++ b/shells/php/default.nix @@ -0,0 +1,16 @@ +{ + callPackage, + mkShell, + php80, + php80Packages, +}: +mkShell { + buildInputs = [ + php80 + php80Packages.composer + ]; + + passthru = { + osu-web = callPackage ./osu-web.nix {}; + }; +} diff --git a/shells/php/osu-web.nix b/shells/php/osu-web.nix new file mode 100644 index 0000000..582979b --- /dev/null +++ b/shells/php/osu-web.nix @@ -0,0 +1,26 @@ +# Flake for development on https://github.com/ppy/osu-web +{ + mkShell, + nodejs-14_x, + nodePackages, + php80, + php80Packages, + python3 +}: +let + phpPkg = php80.withExtensions ({ enabled, all }: + enabled ++ [ all.intl all.redis ] + ); +in mkShell { + buildInputs = [ + nodejs-14_x + nodePackages.yarn + phpPkg + php80Packages.composer + python3 + ]; + + shellHook = '' + export PATH="$(readlink -f ./node_modules/.bin):$PATH" + ''; +} diff --git a/shells/rust/default.nix b/shells/rust/default.nix new file mode 100644 index 0000000..65f1877 --- /dev/null +++ b/shells/rust/default.nix @@ -0,0 +1,25 @@ +{ + inputs, + mkShell, + + pkg-config +}: +let + overlays = [ (import inputs.rust-overlay) ]; + pkgs = import inputs.nixpkgs { + inherit system overlays; + }; + + toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain; + + rustPlatform = pkgs.makeRustPlatform { + inherit (toolchain) cargo rustc; + }; +in mkShell { + nativeBuildInputs = [ + toolchain + pkg-config + ]; + + RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; +}