diff --git a/flake.lock b/flake.lock index 44c7289f68..4489c2f0e1 100644 --- a/flake.lock +++ b/flake.lock @@ -16,22 +16,6 @@ "type": "github" } }, - "devshell": { - "flake": false, - "locked": { - "lastModified": 1667210711, - "narHash": "sha256-IoErjXZAkzYWHEpQqwu/DeRNJGFdR7X2OGbkhMqMrpw=", - "owner": "numtide", - "repo": "devshell", - "rev": "96a9dd12b8a447840cc246e17a47b81a4268bba7", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "devshell", - "type": "github" - } - }, "dream2nix": { "inputs": { "alejandra": [ @@ -42,10 +26,12 @@ ], "crane": "crane", "devshell": [ - "nci", - "devshell" + "nci" + ], + "flake-parts": [ + "nci", + "parts" ], - "flake-parts": "flake-parts", "flake-utils-pre-commit": [ "nci" ], @@ -70,14 +56,17 @@ ], "pre-commit-hooks": [ "nci" + ], + "pruned-racket-catalog": [ + "nci" ] }, "locked": { - "lastModified": 1671323629, - "narHash": "sha256-9KHTPjIDjfnzZ4NjpE3gGIVHVHopy6weRDYO/7Y3hF8=", + "lastModified": 1677289985, + "narHash": "sha256-lUp06cTTlWubeBGMZqPl9jODM99LpWMcwxRiscFAUJg=", "owner": "nix-community", "repo": "dream2nix", - "rev": "2d7d68505c8619410df2c6b6463985f97cbcba6e", + "rev": "28b973a8d4c30cc1cbb3377ea2023a76bc3fb889", "type": "github" }, "original": { @@ -86,37 +75,38 @@ "type": "github" } }, - "flake-parts": { - "inputs": { - "nixpkgs-lib": "nixpkgs-lib" - }, + "mk-naked-shell": { + "flake": false, "locked": { - "lastModified": 1668450977, - "narHash": "sha256-cfLhMhnvXn6x1vPm+Jow3RiFAUSCw/l1utktCw5rVA4=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "d591857e9d7dd9ddbfba0ea02b43b927c3c0f1fa", + "lastModified": 1676572903, + "narHash": "sha256-oQoDHHUTxNVSURfkFcYLuAK+btjs30T4rbEUtCUyKy8=", + "owner": "yusdacra", + "repo": "mk-naked-shell", + "rev": "aeca9f8aa592f5e8f71f407d081cb26fd30c5a57", "type": "github" }, "original": { - "owner": "hercules-ci", - "repo": "flake-parts", + "owner": "yusdacra", + "repo": "mk-naked-shell", "type": "github" } }, "nci": { "inputs": { - "devshell": "devshell", "dream2nix": "dream2nix", - "nixpkgs": "nixpkgs", + "mk-naked-shell": "mk-naked-shell", + "nixpkgs": [ + "nixpkgs" + ], + "parts": "parts", "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1671400340, - "narHash": "sha256-VvRL3w+TbnlB1d9eXNJjuJQOYUL64kXA5508lV9Dq5E=", + "lastModified": 1677302541, + "narHash": "sha256-FqXEoPXguxpGUbGsPNO5M1NahA2K8O1W94ffHNUtk2c=", "owner": "yusdacra", "repo": "nix-cargo-integration", - "rev": "7d894cd374f6394482c8de234c8a8cdeaf8908a5", + "rev": "30787e470b77f6d76a9d4e5878ab3dbfc28c6984", "type": "github" }, "original": { @@ -127,15 +117,15 @@ }, "nixpkgs": { "locked": { - "lastModified": 1671200928, - "narHash": "sha256-mZfzDyzojwj6I0wyooIjGIn81WtGVnx6+avU5Wv+VKU=", - "owner": "NixOS", + "lastModified": 1677063315, + "narHash": "sha256-qiB4ajTeAOVnVSAwCNEEkoybrAlA+cpeiBxLobHndE8=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "757b82211463dd5ba1475b6851d3731dfe14d377", + "rev": "988cc958c57ce4350ec248d2d53087777f9e1949", "type": "github" }, "original": { - "owner": "NixOS", + "owner": "nixos", "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" @@ -144,11 +134,11 @@ "nixpkgs-lib": { "locked": { "dir": "lib", - "lastModified": 1665349835, - "narHash": "sha256-UK4urM3iN80UXQ7EaOappDzcisYIuEURFRoGQ/yPkug=", + "lastModified": 1675183161, + "narHash": "sha256-Zq8sNgAxDckpn7tJo7V1afRSk2eoVbu3OjI1QklGLNg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "34c5293a71ffdb2fe054eb5288adc1882c1eb0b1", + "rev": "e1e1b192c1a5aab2960bf0a0bd53a2e8124fa18e", "type": "github" }, "original": { @@ -159,19 +149,60 @@ "type": "github" } }, + "parts": { + "inputs": { + "nixpkgs-lib": [ + "nci", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1675933616, + "narHash": "sha256-/rczJkJHtx16IFxMmAWu5nNYcSXNg1YYXTHoGjLrLUA=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "47478a4a003e745402acf63be7f9a092d51b83d7", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1675933616, + "narHash": "sha256-/rczJkJHtx16IFxMmAWu5nNYcSXNg1YYXTHoGjLrLUA=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "47478a4a003e745402acf63be7f9a092d51b83d7", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "root": { "inputs": { - "nci": "nci" + "nci": "nci", + "nixpkgs": "nixpkgs", + "parts": "parts_2" } }, "rust-overlay": { "flake": false, "locked": { - "lastModified": 1671330075, - "narHash": "sha256-20Pa/jOxfE6QX4bnQReKjXgrnslY6u54wO4tpVkTZQs=", + "lastModified": 1677205778, + "narHash": "sha256-DFe09uzS+8LjGBAAyHkB/5Axs0j/PQ8RLWFzm2FUZLA=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "31f0276dd8bc0dff576394a985e89be4a4995b4e", + "rev": "b91706f9d5a68fecf97b63753da8e9670dff782b", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 9a69eac388..208f36b398 100644 --- a/flake.nix +++ b/flake.nix @@ -1,14 +1,16 @@ { description = "Flake providing Veloren, a multiplayer voxel RPG written in Rust."; + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; inputs.nci.url = "github:yusdacra/nix-cargo-integration"; + inputs.nci.inputs.nixpkgs.follows = "nixpkgs"; + inputs.parts.url = "github:hercules-ci/flake-parts"; - outputs = inputs: let - lib = inputs.nci.inputs.nixpkgs.lib; - ncl = inputs.nci.lib.nci-lib; + outputs = inp: let + lib = inp.nci.inputs.nixpkgs.lib; git = let - sourceInfo = inputs.self.sourceInfo; + sourceInfo = inp.self.sourceInfo; dateTimeFormat = import ./nix/dateTimeFormat.nix; dateTime = dateTimeFormat sourceInfo.lastModified; shortRev = sourceInfo.shortRev or "dirty"; @@ -45,46 +47,61 @@ # filter out unnecessary paths filter = ignorePaths; }; - checkIfLfsIsSetup = pkgs: checkFile: '' - checkFile="${checkFile}" - result="$(${pkgs.file}/bin/file --mime-type $checkFile)" - if [ "$result" = "$checkFile: image/jpeg" ]; then - echo "Git LFS seems to be setup properly." - true - else - echo " - Git Large File Storage (git-lfs) has not been set up correctly. - Most common reasons: - - git-lfs was not installed before cloning this repository. - - This repository was not cloned from the primary GitLab mirror. - - The GitHub mirror does not support LFS. - See the book at https://book.veloren.net/ for details. - Run 'nix-shell -p git git-lfs --run \"git lfs install --local && git lfs fetch && git lfs checkout\"' - or 'nix shell nixpkgs#git-lfs nixpkgs#git -c sh -c \"git lfs install --local && git lfs fetch && git lfs checkout\"'. - " - false - fi - ''; in - inputs.nci.lib.makeOutputs { - root = ./.; - config = common: { - cCompiler.package = common.pkgs.clang; - outputs.defaults = { - package = "veloren-voxygen"; - app = "veloren-voxygen"; - }; - shell = { - startup.checkLfsSetup.text = '' - ${checkIfLfsIsSetup common.pkgs "$PWD/assets/voxygen/background/bg_main.jpg"} - if [ $? -ne 0 ]; then - exit 1 - fi + inp.parts.lib.mkFlake {inputs = inp;} { + imports = [inp.nci.flakeModule]; + systems = ["x86_64-linux"]; + perSystem = { + config, + pkgs, + lib, + ... + }: let + checkIfLfsIsSetup = checkFile: '' + checkFile="${checkFile}" + result="$(${pkgs.file}/bin/file --mime-type $checkFile)" + if [ "$result" = "$checkFile: image/jpeg" ]; then + echo "Git LFS seems to be setup properly." + true + else + echo " + Git Large File Storage (git-lfs) has not been set up correctly. + Most common reasons: + - git-lfs was not installed before cloning this repository. + - This repository was not cloned from the primary GitLab mirror. + - The GitHub mirror does not support LFS. + See the book at https://book.veloren.net/ for details. + Run 'nix-shell -p git git-lfs --run \"git lfs install --local && git lfs fetch && git lfs checkout\"' + or 'nix shell nixpkgs#git-lfs nixpkgs#git -c sh -c \"git lfs install --local && git lfs fetch && git lfs checkout\"'. + " + false + fi + ''; + assets = pkgs.runCommand "veloren-assets" {} '' + mkdir $out + ln -sf ${./assets} $out/assets + ${checkIfLfsIsSetup "$out/assets/voxygen/background/bg_main.jpg"} + ''; + wrapWithAssets = old: + pkgs.runCommand + old.name + { + inherit (old) pname version; + meta = old.meta or {}; + passthru = + (old.passthru or {}) + // { + unwrapped = old; + }; + nativeBuildInputs = [pkgs.makeWrapper]; + } + '' + cp -rs --no-preserve=mode,ownership ${old} $out + wrapProgram $out/bin/* \ + --set VELOREN_ASSETS ${assets} \ + --set VELOREN_GIT_VERSION "${git.prettyRev}" \ + --set VELOREN_GIT_TAG "${git.tag}" ''; - }; - }; - pkgConfig = common: let - inherit (common) pkgs; veloren-common-ov = { # We don't add in any information here because otherwise anything # that depends on common will be recompiled. We will set these in @@ -92,12 +109,78 @@ NIX_GIT_HASH = ""; NIX_GIT_TAG = ""; }; - assets = pkgs.runCommand "veloren-assets" {} '' - mkdir $out - ln -sf ${./assets} $out/assets - ${checkIfLfsIsSetup pkgs "$out/assets/voxygen/background/bg_main.jpg"} - ''; - wrapWithAssets = _: old: let + voxygenOut = config.nci.outputs."veloren-voxygen"; + serverCliOut = config.nci.outputs."veloren-server-cli"; + in { + packages.veloren-voxygen = wrapWithAssets voxygenOut.packages.release; + packages.veloren-voxygen-dev = wrapWithAssets voxygenOut.packages.dev; + packages.veloren-server-cli = wrapWithAssets serverCliOut.packages.release; + packages.veloren-server-cli-dev = wrapWithAssets serverCliOut.packages.dev; + packages.default = config.packages."veloren-voxygen"; + + devShells.default = config.nci.outputs."veloren".devShell.overrideAttrs (old: { + shellHook = '' + ${checkIfLfsIsSetup "$PWD/assets/voxygen/background/bg_main.jpg"} + if [ $? -ne 0 ]; then + exit 1 + fi + ''; + }); + + nci.projects."veloren".relPath = ""; + nci.crates."veloren-server-cli" = let + veloren-server-cli-deps-ov = _: { + doCheck = false; + dontCheck = true; + }; + in { + profiles = { + release.features = ["default-publish"]; + dev.features = ["default-publish"]; + }; + depsOverrides.fix-build.overrideAttrs = veloren-server-cli-deps-ov; + overrides = { + fix-veloren-common = veloren-common-ov; + add-deps-reqs.overrideAttrs = veloren-server-cli-deps-ov; + fix-build.override = _: { + src = filteredSource; + VELOREN_USERDATA_STRATEGY = "system"; + }; + }; + }; + nci.crates."veloren-voxygen" = let + veloren-voxygen-deps-ov = prev: { + buildInputs = + (prev.buildInputs or []) + ++ ( + with pkgs; [ + alsa-lib + libxkbcommon + udev + xorg.libxcb + ] + ); + nativeBuildInputs = + (prev.nativeBuildInputs or []) + ++ ( + with pkgs; [ + python3 + pkg-config + cmake + gnumake + ] + ); + + SHADERC_LIB_DIR = "${pkgs.shaderc.lib}/lib"; + VELOREN_ASSETS = "${assets}"; + + checkPhase = ":"; + }; + in { + profiles = { + release.features = ["default-publish"]; + dev.features = ["default-publish"]; + }; runtimeLibs = with pkgs; [ xorg.libX11 xorg.libXi @@ -109,48 +192,8 @@ udev alsa-lib vulkan-loader + stdenv.cc.cc.lib ]; - wrapped = - common.internal.pkgsSet.utils.wrapDerivation old - {nativeBuildInputs = [pkgs.makeWrapper];} - '' - rm -rf $out/bin - mkdir $out/bin - ln -sf ${old}/bin/* $out/bin/ - wrapProgram $out/bin/* \ - ${lib.optionalString (old.pname == "veloren-voxygen") "--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath runtimeLibs}"} \ - --set VELOREN_ASSETS ${assets} \ - --set VELOREN_GIT_VERSION "${git.prettyRev}" \ - --set VELOREN_GIT_TAG "${git.tag}" - ''; - in - wrapped; - in { - veloren-voxygen = let - veloren-voxygen-deps-ov = oldAttrs: { - buildInputs = ncl.addBuildInputs oldAttrs ( - with pkgs; [ - alsa-lib - libxkbcommon - udev - xorg.libxcb - ] - ); - nativeBuildInputs = - ncl.addNativeBuildInputs oldAttrs (with pkgs; [python3 pkg-config]); - - SHADERC_LIB_DIR = "${pkgs.shaderc.lib}/lib"; - VELOREN_ASSETS = "${assets}"; - - doCheck = false; - dontCheck = true; - }; - in { - features = { - release = ["default-publish"]; - dev = ["default-publish"]; - test = ["default-publish"]; - }; depsOverrides.fix-build.overrideAttrs = veloren-voxygen-deps-ov; overrides = { fix-veloren-common = veloren-common-ov; @@ -171,29 +214,6 @@ ''; }; }; - wrapper = wrapWithAssets; - }; - veloren-server-cli = let - veloren-server-cli-deps-ov = oldAttrs: { - doCheck = false; - dontCheck = true; - }; - in { - features = { - release = ["default-publish"]; - dev = ["default-publish"]; - test = ["default-publish"]; - }; - depsOverrides.fix-build.overrideAttrs = veloren-server-cli-deps-ov; - overrides = { - fix-veloren-common = veloren-common-ov; - add-deps-reqs.overrideAttrs = veloren-server-cli-deps-ov; - fix-build = { - src = filteredSource; - VELOREN_USERDATA_STRATEGY = "system"; - }; - }; - wrapper = wrapWithAssets; }; }; };