fix: update flake

This commit is contained in:
Yusuf Bera Ertan 2022-12-18 04:25:07 +03:00
parent 1798cdcffe
commit dd6c33bab7
No known key found for this signature in database
GPG Key ID: 1D8F8FAF2294D6EA
3 changed files with 225 additions and 167 deletions

View File

@ -3,11 +3,11 @@
"crane": {
"flake": false,
"locked": {
"lastModified": 1661875961,
"narHash": "sha256-f1h/2c6Teeu1ofAHWzrS8TwBPcnN+EEu+z1sRVmMQTk=",
"lastModified": 1670900067,
"narHash": "sha256-VXVa+KBfukhmWizaiGiHRVX/fuk66P8dgSFfkVN4/MY=",
"owner": "ipetkov",
"repo": "crane",
"rev": "d9f394e4e20e97c2a60c3ad82c2b6ef99be19e24",
"rev": "59b31b41a589c0a65e4a1f86b0e5eac68081468b",
"type": "github"
},
"original": {
@ -19,11 +19,11 @@
"devshell": {
"flake": false,
"locked": {
"lastModified": 1660811669,
"narHash": "sha256-V6lmsaLNFz41myppL0yxglta92ijkSvpZ+XVygAh+bU=",
"lastModified": 1667210711,
"narHash": "sha256-IoErjXZAkzYWHEpQqwu/DeRNJGFdR7X2OGbkhMqMrpw=",
"owner": "numtide",
"repo": "devshell",
"rev": "c2feacb46ee69949124c835419861143c4016fb5",
"rev": "96a9dd12b8a447840cc246e17a47b81a4268bba7",
"type": "github"
},
"original": {
@ -35,45 +35,49 @@
"dream2nix": {
"inputs": {
"alejandra": [
"nci",
"nixpkgs"
"nci"
],
"all-cabal-json": [
"nci"
],
"crane": "crane",
"devshell": [
"nci",
"devshell"
],
"flake-parts": "flake-parts",
"flake-utils-pre-commit": [
"nci",
"nixpkgs"
"nci"
],
"ghc-utils": [
"nci"
],
"gomod2nix": [
"nci",
"nixpkgs"
"nci"
],
"mach-nix": [
"nci",
"nixpkgs"
"nci"
],
"nix-pypi-fetcher": [
"nci"
],
"nixpkgs": [
"nci",
"nixpkgs"
],
"poetry2nix": [
"nci",
"nixpkgs"
"nci"
],
"pre-commit-hooks": [
"nci",
"nixpkgs"
"nci"
]
},
"locked": {
"lastModified": 1662507674,
"narHash": "sha256-vnXfje4pfTqDEqI837GCT+hNKqzfVwPen++gnLVO9F0=",
"lastModified": 1671323629,
"narHash": "sha256-9KHTPjIDjfnzZ4NjpE3gGIVHVHopy6weRDYO/7Y3hF8=",
"owner": "nix-community",
"repo": "dream2nix",
"rev": "5ba9061857e3e265538c9785bb56bda2bb8f9bca",
"rev": "2d7d68505c8619410df2c6b6463985f97cbcba6e",
"type": "github"
},
"original": {
@ -82,6 +86,24 @@
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1668450977,
"narHash": "sha256-cfLhMhnvXn6x1vPm+Jow3RiFAUSCw/l1utktCw5rVA4=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "d591857e9d7dd9ddbfba0ea02b43b927c3c0f1fa",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nci": {
"inputs": {
"devshell": "devshell",
@ -90,11 +112,11 @@
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1662507702,
"narHash": "sha256-Q8zfpLNCJublP7t4oHizr5tgsCS4BHFk7Fc7wzWbrzE=",
"lastModified": 1671326550,
"narHash": "sha256-FmGeaTd9FF64jhA8+J3ZJtFROQtfjeu1WESp+DRsVfg=",
"owner": "yusdacra",
"repo": "nix-cargo-integration",
"rev": "97aa58c683ccf628175118052b3306f40ac21ca0",
"rev": "44c525562513cd818e515f556fa4b7393939cc8e",
"type": "github"
},
"original": {
@ -105,11 +127,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1662019588,
"narHash": "sha256-oPEjHKGGVbBXqwwL+UjsveJzghWiWV0n9ogo1X6l4cw=",
"lastModified": 1671200928,
"narHash": "sha256-mZfzDyzojwj6I0wyooIjGIn81WtGVnx6+avU5Wv+VKU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "2da64a81275b68fdad38af669afeda43d401e94b",
"rev": "757b82211463dd5ba1475b6851d3731dfe14d377",
"type": "github"
},
"original": {
@ -119,6 +141,24 @@
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1665349835,
"narHash": "sha256-UK4urM3iN80UXQ7EaOappDzcisYIuEURFRoGQ/yPkug=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "34c5293a71ffdb2fe054eb5288adc1882c1eb0b1",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nci": "nci"
@ -127,11 +167,11 @@
"rust-overlay": {
"flake": false,
"locked": {
"lastModified": 1662433378,
"narHash": "sha256-DqMtTtIownl+UIPG1O917IH10UF0Hwql636p22vOJfw=",
"lastModified": 1671243596,
"narHash": "sha256-vQ1q6uwx2gKsHbQVhkq17nT8HwUmRbIG8cJVFafNb5s=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "12aa8ea4381b28b7a3118f96682dc3ffb13fb6b6",
"rev": "905db21103d646ddc1eb81920e05180e6e2b6734",
"type": "github"
},
"original": {

263
flake.nix
View File

@ -29,6 +29,8 @@
"CODE_OF_CONDUCT.md"
"clippy.toml"
".cargo"
".github"
".gitlab"
];
ignorePaths = path: type: let
split = lib.splitString "/" path;
@ -43,105 +45,93 @@
# filter out unnecessary paths
filter = ignorePaths;
};
wrapWithAssets = common: _: old: let
pkgs = common.pkgs;
runtimeLibs = with pkgs; [
xorg.libX11
xorg.libXi
xorg.libxcb
xorg.libXcursor
xorg.libXrandr
libxkbcommon
shaderc.lib
udev
alsa-lib
vulkan-loader
];
assets = pkgs.runCommand "veloren-assets" {} ''
mkdir $out
ln -sf ${./assets} $out/assets
# check if LFS was setup properly
checkFile="$out/assets/voxygen/background/bg_main.jpg"
result="$(${pkgs.file}/bin/file --mime-type $checkFile)"
if [ "$result" = "$checkFile: image/jpeg" ]; then
echo "Git LFS seems to be setup properly."
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
'';
wrapped =
common.internal.nci-pkgs.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;
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 = ./.;
defaultOutputs = {
package = "veloren-voxygen";
app = "veloren-voxygen";
};
perCrateOverrides = {
veloren-voxygen = {
packageMetadata = _: {
features = rec {
release = ["default-publish"];
debug = release;
test = release;
};
};
wrapper = wrapWithAssets;
config = common: {
cCompiler.package = common.pkgs.clang;
outputs.defaults = {
package = "veloren-voxygen";
app = "veloren-voxygen";
};
veloren-server-cli.wrapper = wrapWithAssets;
};
disableVendoredCrateOverrides = true;
overrides = {
cCompiler = common: common.pkgs.clang;
crates = common: prev: let
pkgs = common.pkgs;
configMoldLinker = ''
touch $CARGO_HOME/config.toml
cat >>$CARGO_HOME/config.toml <<EOF
[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=mold"]
EOF
shell = {
startup.checkLfsSetup.text = ''
${checkIfLfsIsSetup common.pkgs "$PWD/assets/voxygen/background/bg_main.jpg"}
if [ $? -ne 0 ]; then
exit 1
fi
'';
in rec {
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 = true;
# We don't add in any information here because otherwise anything
# that depends on common will be recompiled. We will set these in
# our wrapper instead.
NIX_GIT_HASH = "";
NIX_GIT_TAG = "";
};
veloren-voxygen-deps = oldAttrs: {
buildInputs = ncl.addBuildInputs prev (
};
};
pkgConfig = common: let
inherit (common) pkgs;
veloren-common-ov = {
# 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 = true;
# We don't add in any information here because otherwise anything
# that depends on common will be recompiled. We will set these in
# our wrapper instead.
NIX_GIT_HASH = "";
NIX_GIT_TAG = "";
};
wrapWithAssets = _: old: let
runtimeLibs = with pkgs; [
xorg.libX11
xorg.libXi
xorg.libxcb
xorg.libXcursor
xorg.libXrandr
libxkbcommon
shaderc.lib
udev
alsa-lib
vulkan-loader
];
assets = pkgs.runCommand "veloren-assets" {} ''
mkdir $out
ln -sf ${./assets} $out/assets
${checkIfLfsIsSetup pkgs "$out/assets/voxygen/background/bg_main.jpg"}
'';
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
@ -150,55 +140,62 @@
]
);
nativeBuildInputs =
ncl.addNativeBuildInputs prev (with pkgs; [python3 pkg-config mold]);
ncl.addNativeBuildInputs oldAttrs (with pkgs; [python3 pkg-config]);
SHADERC_LIB_DIR = "${pkgs.shaderc.lib}/lib";
doCheck = false;
postConfigure = ''
${oldAttrs.postConfigure or ""}
${configMoldLinker}
'';
dontCheck = true;
};
veloren-voxygen = prev:
ncl.computeOverridesResult prev [
veloren-voxygen-deps
(oldAttrs: {
src = filteredSource;
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;
add-deps-reqs.overrideAttrs = veloren-voxygen-deps-ov;
fix-build.overrideAttrs = prev: {
src = filteredSource;
VELOREN_USERDATA_STRATEGY = "system";
VELOREN_USERDATA_STRATEGY = "system";
dontUseCmakeConfigure = true;
preConfigure = ''
${oldAttrs.preConfigure or ""}
substituteInPlace voxygen/src/audio/soundcache.rs \
--replace \
"../../../assets/voxygen/audio/null.ogg" \
"${./assets/voxygen/audio/null.ogg}"
'';
})
];
veloren-server-cli-deps = oldAttrs: {
nativeBuildInputs = ncl.addNativeBuildInputs prev [pkgs.mold];
dontUseCmakeConfigure = true;
preConfigure = ''
${prev.preConfigure or ""}
substituteInPlace voxygen/src/audio/soundcache.rs \
--replace \
"../../../assets/voxygen/audio/null.ogg" \
"${./assets/voxygen/audio/null.ogg}"
'';
};
};
wrapper = wrapWithAssets;
};
veloren-server-cli = let
veloren-server-cli-deps-ov = oldAttrs: {
doCheck = false;
postConfigure = ''
${oldAttrs.postConfigure or ""}
${configMoldLinker}
'';
dontCheck = true;
};
veloren-server-cli = prev:
ncl.computeOverridesResult prev [
veloren-server-cli-deps
(oldAttrs: {
src = filteredSource;
VELOREN_USERDATA_STRATEGY = "system";
})
];
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;
};
};
};

View File

@ -7,15 +7,36 @@ t: let
# Courtesy of https://stackoverflow.com/a/32158604.
z = days + 719468;
era = (if z >= 0 then z else z - 146096) / 146097;
era =
(
if z >= 0
then z
else z - 146096
)
/ 146097;
doe = z - era * 146097;
yoe = (doe - doe / 1460 + doe / 36524 - doe / 146096) / 365;
y = yoe + era * 400;
doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
mp = (5 * doy + 2) / 153;
d = doy - (153 * mp + 2) / 5 + 1;
m = mp + (if mp < 10 then 3 else -9);
y' = y + (if m <= 2 then 1 else 0);
m =
mp
+ (
if mp < 10
then 3
else -9
);
y' =
y
+ (
if m <= 2
then 1
else 0
);
pad = s: if builtins.stringLength s < 2 then "0" + s else s;
pad = s:
if builtins.stringLength s < 2
then "0" + s
else s;
in "${toString y'}-${pad (toString m)}-${pad (toString d)}-${pad (toString hours)}:${pad (toString minutes)}"