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

263
flake.nix
View File

@ -29,6 +29,8 @@
"CODE_OF_CONDUCT.md" "CODE_OF_CONDUCT.md"
"clippy.toml" "clippy.toml"
".cargo" ".cargo"
".github"
".gitlab"
]; ];
ignorePaths = path: type: let ignorePaths = path: type: let
split = lib.splitString "/" path; split = lib.splitString "/" path;
@ -43,105 +45,93 @@
# filter out unnecessary paths # filter out unnecessary paths
filter = ignorePaths; filter = ignorePaths;
}; };
checkIfLfsIsSetup = pkgs: checkFile: ''
wrapWithAssets = common: _: old: let checkFile="${checkFile}"
pkgs = common.pkgs; result="$(${pkgs.file}/bin/file --mime-type $checkFile)"
runtimeLibs = with pkgs; [ if [ "$result" = "$checkFile: image/jpeg" ]; then
xorg.libX11 echo "Git LFS seems to be setup properly."
xorg.libXi true
xorg.libxcb else
xorg.libXcursor echo "
xorg.libXrandr Git Large File Storage (git-lfs) has not been set up correctly.
libxkbcommon Most common reasons:
shaderc.lib - git-lfs was not installed before cloning this repository.
udev - This repository was not cloned from the primary GitLab mirror.
alsa-lib - The GitHub mirror does not support LFS.
vulkan-loader 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\"'
assets = pkgs.runCommand "veloren-assets" {} '' or 'nix shell nixpkgs#git-lfs nixpkgs#git -c sh -c \"git lfs install --local && git lfs fetch && git lfs checkout\"'.
mkdir $out "
ln -sf ${./assets} $out/assets false
# check if LFS was setup properly fi
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;
in in
inputs.nci.lib.makeOutputs { inputs.nci.lib.makeOutputs {
root = ./.; root = ./.;
defaultOutputs = { config = common: {
package = "veloren-voxygen"; cCompiler.package = common.pkgs.clang;
app = "veloren-voxygen"; outputs.defaults = {
}; package = "veloren-voxygen";
perCrateOverrides = { app = "veloren-voxygen";
veloren-voxygen = {
packageMetadata = _: {
features = rec {
release = ["default-publish"];
debug = release;
test = release;
};
};
wrapper = wrapWithAssets;
}; };
veloren-server-cli.wrapper = wrapWithAssets; shell = {
}; startup.checkLfsSetup.text = ''
disableVendoredCrateOverrides = true; ${checkIfLfsIsSetup common.pkgs "$PWD/assets/voxygen/background/bg_main.jpg"}
overrides = { if [ $? -ne 0 ]; then
cCompiler = common: common.pkgs.clang; exit 1
crates = common: prev: let fi
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
''; '';
in rec { };
veloren-common = oldAttrs: { };
# Disable `git-lfs` check here since we check it ourselves pkgConfig = common: let
# We have to include the command output here, otherwise Nix won't run it inherit (common) pkgs;
DISABLE_GIT_LFS_CHECK = true; veloren-common-ov = {
# We don't add in any information here because otherwise anything # Disable `git-lfs` check here since we check it ourselves
# that depends on common will be recompiled. We will set these in # We have to include the command output here, otherwise Nix won't run it
# our wrapper instead. DISABLE_GIT_LFS_CHECK = true;
NIX_GIT_HASH = ""; # We don't add in any information here because otherwise anything
NIX_GIT_TAG = ""; # that depends on common will be recompiled. We will set these in
}; # our wrapper instead.
veloren-voxygen-deps = oldAttrs: { NIX_GIT_HASH = "";
buildInputs = ncl.addBuildInputs prev ( 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; [ with pkgs; [
alsa-lib alsa-lib
libxkbcommon libxkbcommon
@ -150,55 +140,62 @@
] ]
); );
nativeBuildInputs = 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"; SHADERC_LIB_DIR = "${pkgs.shaderc.lib}/lib";
doCheck = false; doCheck = false;
dontCheck = true;
postConfigure = ''
${oldAttrs.postConfigure or ""}
${configMoldLinker}
'';
}; };
veloren-voxygen = prev: in {
ncl.computeOverridesResult prev [ features = {
veloren-voxygen-deps release = ["default-publish"];
(oldAttrs: { dev = ["default-publish"];
src = filteredSource; 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; 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];
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; doCheck = false;
dontCheck = true;
postConfigure = ''
${oldAttrs.postConfigure or ""}
${configMoldLinker}
'';
}; };
veloren-server-cli = prev: in {
ncl.computeOverridesResult prev [ features = {
veloren-server-cli-deps release = ["default-publish"];
(oldAttrs: { dev = ["default-publish"];
src = filteredSource; test = ["default-publish"];
};
VELOREN_USERDATA_STRATEGY = "system"; 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. # Courtesy of https://stackoverflow.com/a/32158604.
z = days + 719468; 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; doe = z - era * 146097;
yoe = (doe - doe / 1460 + doe / 36524 - doe / 146096) / 365; yoe = (doe - doe / 1460 + doe / 36524 - doe / 146096) / 365;
y = yoe + era * 400; y = yoe + era * 400;
doy = doe - (365 * yoe + yoe / 4 - yoe / 100); doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
mp = (5 * doy + 2) / 153; mp = (5 * doy + 2) / 153;
d = doy - (153 * mp + 2) / 5 + 1; d = doy - (153 * mp + 2) / 5 + 1;
m = mp + (if mp < 10 then 3 else -9); m =
y' = y + (if m <= 2 then 1 else 0); 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)}" in "${toString y'}-${pad (toString m)}-${pad (toString d)}-${pad (toString hours)}:${pad (toString minutes)}"