Merge branch 'yusdacra/chore/nix' into 'master'

build(nix): fix nix builds

See merge request veloren/veloren!2437
This commit is contained in:
Marcel 2021-06-13 17:11:52 +00:00
commit 830b6e802e
3 changed files with 105 additions and 171 deletions

View File

@ -109,10 +109,6 @@ key = "veloren-nix.cachix.org-1:zokfKJqVsNV6kI/oJdLF6TYBdNPYGSb+diMVQPn/5Rc="
buildInputs = ["openssl"]
nativeBuildInputs = ["pkg-config"]
[workspace.metadata.nix.crateOverride.shaderc-sys]
buildInputs = ["shaderc"]
nativeBuildInputs = ["cmake", "python3", "gnumake"]
[patch.crates-io]
# macos CI fix isn't released yet
winit = { git = "https://gitlab.com/veloren/winit.git", branch = "macos-test-spiffed" }

View File

@ -1,22 +1,5 @@
{
"nodes": {
"crate2nix": {
"flake": false,
"locked": {
"lastModified": 1619462726,
"narHash": "sha256-bQuUBOGzPnL3S+aweK/P9WRfNGk/tuoLDPfzIiX7XXY=",
"owner": "yusdacra",
"repo": "crate2nix",
"rev": "e10f71834d1464cd4b07d1bf7965c65abbff3fab",
"type": "github"
},
"original": {
"owner": "yusdacra",
"ref": "feat/builtinfetchgit",
"repo": "crate2nix",
"type": "github"
}
},
"devshell": {
"locked": {
"lastModified": 1622711433,
@ -32,56 +15,20 @@
"type": "github"
}
},
"flakeUtils": {
"locked": {
"lastModified": 1622445595,
"narHash": "sha256-m+JRe6Wc5OZ/mKw2bB3+Tl0ZbtyxxxfnAWln8Q5qs+Y=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "7d706970d94bc5559077eb1a6600afddcd25a7c8",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"naersk": {
"flake": false,
"locked": {
"lastModified": 1619312121,
"narHash": "sha256-Zx1rTlonsp54lVlnIg38HV3bYx6GdIoKS1SgDnV+YBY=",
"owner": "yusdacra",
"repo": "naersk",
"rev": "07d0b56bdbd353a705f26b799e3a125c7be0f8c3",
"type": "github"
},
"original": {
"owner": "yusdacra",
"ref": "feat/cargolock-git-deps",
"repo": "naersk",
"type": "github"
}
},
"nixCargoIntegration": {
"inputs": {
"crate2nix": "crate2nix",
"devshell": "devshell",
"flakeUtils": "flakeUtils",
"naersk": "naersk",
"nixpkgs": [
"nixpkgs"
],
"preCommitHooks": "preCommitHooks",
"rustOverlay": "rustOverlay"
},
"locked": {
"lastModified": 1622713739,
"narHash": "sha256-+X+MJno3JKwrtJxLbl37/0YihznIfjowRyxeEwoFEk0=",
"lastModified": 1623601923,
"narHash": "sha256-zQDRV3OMYKlewfp3k0ilmFNfcFDxBCCk0tbcde8HMYM=",
"owner": "yusdacra",
"repo": "nix-cargo-integration",
"rev": "f383dd1d1915ec1fc38d855fe9351d8f5778211e",
"rev": "ab922adefdeb387ce105b1bde75f62ffb971cec4",
"type": "github"
},
"original": {
@ -92,11 +39,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1622368643,
"narHash": "sha256-/BEAmTreS2JjRvnuNNr65tA20FWcRsonURKfYdJecJA=",
"lastModified": 1623176226,
"narHash": "sha256-54a9uvHlIlK3i0b36HfGMc4zqM0BpMOOiFYBxEhQFK8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "774fe1878b045411e6bdd0dd90d8581e82b10993",
"rev": "51bb9f3e9ab6161a3bf7746e20b955712cef618b",
"type": "github"
},
"original": {
@ -106,22 +53,6 @@
"type": "github"
}
},
"preCommitHooks": {
"flake": false,
"locked": {
"lastModified": 1622650193,
"narHash": "sha256-qSzUpJDv04ajS9FXoCq6NjVF3qOt9IiGIiGh0P8amyw=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "0398f0649e0a741660ac5e8216760bae5cc78579",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"nixCargoIntegration": "nixCargoIntegration",
@ -131,11 +62,11 @@
"rustOverlay": {
"flake": false,
"locked": {
"lastModified": 1622689331,
"narHash": "sha256-b8c0t2Uo4uk7DNhSfhFDpqzY/w/tIUgBut5Ug1Pl6DU=",
"lastModified": 1623550815,
"narHash": "sha256-RumRrkE6OTJDndHV4qZNZv8kUGnzwRHZQSyzx29r6/g=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "7ad7640ad12ff6b0af4f96bffd95175ad0898d49",
"rev": "9824f142cbd7bc3e2a92eefbb79addfff8704cd3",
"type": "github"
},
"original": {

185
flake.nix
View File

@ -10,95 +10,102 @@
};
outputs = inputs:
let
output = inputs.nixCargoIntegration.lib.makeOutputs {
root = ./.;
buildPlatform = "crate2nix";
overrides = {
build = common: prev: {
runTests = !prev.release && prev.runTests;
};
crateOverrides = common: prev:
let
pkgs = common.pkgs;
lib = common.lib;
gitLfsCheckFile = ./assets/voxygen/background/bg_main.png;
utils = import ./nix/utils.nix { inherit pkgs; };
sourceInfo =
if inputs.self.sourceInfo ? rev
then inputs.self.sourceInfo // {
# Tag would have to be set manually for stable releases flake
# because there's currently no way to get the tag via the interface.
# tag = v0.9.0;
}
else (throw "Can't get revision because the git tree is dirty");
prettyRev = with sourceInfo; builtins.substring 0 8 rev + "/" + utils.dateTimeFormat lastModified;
tag = with sourceInfo;
if sourceInfo ? tag
then sourceInfo.tag
else "";
# If gitTag has a tag (meaning the commit we are on is a *release*), use
# it as version, else: just use the prettified hash we have, if we don't
# have it the build fails.
# Must be in format f4987672/2020-12-10-12:00
version =
if tag != "" then tag
else if prettyRev != "" then prettyRev
else throw "Need a tag or pretty revision in order to determine version";
veloren-assets = pkgs.runCommand "makeAssetsDir" { } ''
mkdir $out
ln -sf ${./assets} $out/assets
'';
in
{
# veloren-world = oldAttrs: {
# crateBin = lib.filter (bin: bin.name != "chunk_compression_benchmarks") oldAttrs.crateBin;
# };
veloren-client = oldAttrs: {
crateBin = lib.filter (bin: bin.name != "bot") oldAttrs.crateBin;
};
veloren-common = oldAttrs: {
# Disable `git-lfs` check here since we check it ourselves
# We have to include the command output here, otherwise Nix won't run it
DISABLE_GIT_LFS_CHECK = utils.isGitLfsSetup gitLfsCheckFile;
# Declare env values here so that `common/build.rs` sees them
NIX_GIT_HASH = prettyRev;
NIX_GIT_TAG = tag;
crateBin = lib.filter (bin: bin.name != "csv_export" && bin.name != "csv_import") oldAttrs.crateBin;
};
veloren-voxygen = oldAttrs: {
VELOREN_USERDATA_STRATEGY = "system";
postInstall = ''
if [ -f $out/bin/veloren-voxygen ]; then
wrapProgram $out/bin/veloren-voxygen \
--set VELOREN_ASSETS ${veloren-assets} \
--set LD_LIBRARY_PATH ${lib.makeLibraryPath common.runtimeLibs}
fi
'';
patches = [
(import ./nix/nullOggPatch.nix { nullOgg = ./assets/voxygen/audio/null.ogg; inherit pkgs; })
];
};
veloren-server-cli = oldAttrs: {
VELOREN_USERDATA_STRATEGY = "system";
postInstall = ''
if [ -f $out/bin/veloren-server-cli ]; then
wrapProgram $out/bin/veloren-server-cli --set VELOREN_ASSETS ${veloren-assets}
fi
'';
};
};
};
inputs.nixCargoIntegration.lib.makeOutputs {
root = ./.;
buildPlatform = "crate2nix";
defaultOutputs = {
package = "veloren-voxygen";
app = "veloren-voxygen";
};
overrides = {
build = common: prev: {
runTests = !prev.release && prev.runTests;
};
crateOverrides = common: prev:
let
pkgs = common.pkgs;
lib = common.lib;
gitLfsCheckFile = ./assets/voxygen/background/bg_main.png;
utils = import ./nix/utils.nix { inherit pkgs; };
sourceInfo =
if inputs.self.sourceInfo ? rev
then inputs.self.sourceInfo // {
# Tag would have to be set manually for stable releases flake
# because there's currently no way to get the tag via the interface.
# tag = v0.9.0;
}
else (throw "Can't get revision because the git tree is dirty");
prettyRev = with sourceInfo; builtins.substring 0 8 rev + "/" + utils.dateTimeFormat lastModified;
tag = with sourceInfo;
if sourceInfo ? tag
then sourceInfo.tag
else "";
# If gitTag has a tag (meaning the commit we are on is a *release*), use
# it as version, else: just use the prettified hash we have, if we don't
# have it the build fails.
# Must be in format f4987672/2020-12-10-12:00
version =
if tag != "" then tag
else if prettyRev != "" then prettyRev
else throw "Need a tag or pretty revision in order to determine version";
veloren-assets = pkgs.runCommand "makeAssetsDir" { } ''
mkdir $out
ln -sf ${./assets} $out/assets
'';
in
{
# veloren-world = oldAttrs: {
# crateBin = lib.filter (bin: bin.name != "chunk_compression_benchmarks") oldAttrs.crateBin;
# };
shaderc-sys = _:
let SHADERC_LIB_DIR = "${common.pkgs.shaderc.lib}/lib"; in
{
inherit SHADERC_LIB_DIR;
propagatedEnv = { inherit SHADERC_LIB_DIR; };
};
veloren-client = oldAttrs: {
crateBin = lib.filter (bin: bin.name != "bot") oldAttrs.crateBin;
};
veloren-i18n = oldAttrs: {
crateBin = lib.filter (bin: bin.name != "i18n-check") oldAttrs.crateBin;
};
veloren-common = oldAttrs: {
# Disable `git-lfs` check here since we check it ourselves
# We have to include the command output here, otherwise Nix won't run it
DISABLE_GIT_LFS_CHECK = utils.isGitLfsSetup gitLfsCheckFile;
# Declare env values here so that `common/build.rs` sees them
NIX_GIT_HASH = prettyRev;
NIX_GIT_TAG = tag;
crateBin = lib.filter (bin: bin.name != "csv_export" && bin.name != "csv_import" && bin.name != "recipe_graphviz") oldAttrs.crateBin;
};
veloren-voxygen = oldAttrs: {
VELOREN_USERDATA_STRATEGY = "system";
postInstall = ''
if [ -f $out/bin/veloren-voxygen ]; then
wrapProgram $out/bin/veloren-voxygen \
--set VELOREN_ASSETS ${veloren-assets} \
--set LD_LIBRARY_PATH ${lib.makeLibraryPath common.runtimeLibs}
fi
'';
patches = [
(import ./nix/nullOggPatch.nix { nullOgg = ./assets/voxygen/audio/null.ogg; inherit pkgs; })
];
};
veloren-server-cli = oldAttrs: {
VELOREN_USERDATA_STRATEGY = "system";
postInstall = ''
if [ -f $out/bin/veloren-server-cli ]; then
wrapProgram $out/bin/veloren-server-cli --set VELOREN_ASSETS ${veloren-assets}
fi
'';
};
};
};
in
output // {
defaultApp = builtins.mapAttrs (_: apps: apps.veloren-voxygen) output.apps;
defaultPackage = builtins.mapAttrs (_: packages: packages.veloren-voxygen) output.packages;
};
}