build(nix): switch back to master branch nix-cargo-integration, use defaultOutputs

This commit is contained in:
Yusuf Bera Ertan 2021-06-13 19:33:38 +03:00
parent 27216d9a5e
commit e27a6fcaa1
No known key found for this signature in database
GPG Key ID: 1D8F8FAF2294D6EA
2 changed files with 100 additions and 103 deletions

View File

@ -24,16 +24,15 @@
"rustOverlay": "rustOverlay"
},
"locked": {
"lastModified": 1623594891,
"narHash": "sha256-JmjOTdIW0QIsMoqU6oIQx9fqH0Ims83g2jK8jmokHsI=",
"lastModified": 1623601923,
"narHash": "sha256-zQDRV3OMYKlewfp3k0ilmFNfcFDxBCCk0tbcde8HMYM=",
"owner": "yusdacra",
"repo": "nix-cargo-integration",
"rev": "5394e8fa179346854e44e05edced0b9d7dc818b7",
"rev": "ab922adefdeb387ce105b1bde75f62ffb971cec4",
"type": "github"
},
"original": {
"owner": "yusdacra",
"ref": "fix/crate2nix",
"repo": "nix-cargo-integration",
"type": "github"
}

196
flake.nix
View File

@ -4,110 +4,108 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixCargoIntegration = {
url = "github:yusdacra/nix-cargo-integration/fix/crate2nix";
url = "github:yusdacra/nix-cargo-integration";
inputs.nixpkgs.follows = "nixpkgs";
};
};
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;
# };
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
'';
};
};
};
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;
};
}