Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at python-updates 74 lines 2.6 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 fetchYarnDeps, 6 yarnConfigHook, 7 yarnBuildHook, 8 yarn, 9 fixup-yarn-lock, 10 prefetch-yarn-deps, 11 nodejs_20, 12 nodejs-slim_20, 13 yq-go, 14 settings ? { }, 15}: 16stdenv.mkDerivation (finalAttrs: { 17 pname = "dashy-ui"; 18 # This is like 3.1.1 but the latest working yarn.lock. 19 # All other changes are for docs with the exception of 768d746cbfcf365c58ad1194c5ccc74c14f3ed3a, which simply adds no-referrer meta tag 20 version = "3.1.1-unstable-2024-07-14"; 21 src = fetchFromGitHub { 22 owner = "lissy93"; 23 repo = "dashy"; 24 rev = "0b1af9db483f80323e782e7834da2a337393e111"; 25 hash = "sha256-lRJ3lI9UUIaw9GWPEy81Dbf4cu6rClA4VjdWejVQN+g="; 26 }; 27 yarnOfflineCache = fetchYarnDeps { 28 yarnLock = finalAttrs.src + "/yarn.lock"; 29 hash = "sha256-KVAZIBM47yp1NWYc2esvTwfoAev4q7Wgi0c73PUZRNw="; 30 }; 31 # - If no settings are passed, use the default config provided by upstream 32 # - Despite JSON being valid YAML (and the JSON passing the config validator), 33 # there seem to be some issues with JSON in the final build - potentially due to 34 # the way the client parses things 35 # - Instead, we use `yq-go` to convert it to yaml 36 # Config validation needs to happen after yarnConfigHook, since it's what sets the yarn offline cache 37 preBuild = lib.optional (settings != { }) '' 38 echo "Writing settings override..." 39 yq --output-format yml '${builtins.toFile "conf.json" ''${builtins.toJSON settings}''}' > user-data/conf.yml 40 yarn validate-config --offline 41 ''; 42 installPhase = '' 43 mkdir $out 44 cp -R dist/* $out 45 ''; 46 47 nativeBuildInputs = [ 48 # This is required to fully pin the NodeJS version, since yarn*Hooks pull in the latest LTS in nixpkgs 49 # The yarn override is the only one technically required (fixup-yarn-lock and prefetch-yarn-deps' node version doesn't affect the end result), 50 # but they've been overridden for the sake of consistency/in case future updates to dashy/node would cause issues with differing major versions 51 (yarnConfigHook.override { 52 fixup-yarn-lock = fixup-yarn-lock.override { 53 nodejs-slim = nodejs-slim_20; 54 }; 55 prefetch-yarn-deps = prefetch-yarn-deps.override { 56 nodejs-slim = nodejs-slim_20; 57 }; 58 yarn = yarn.override { 59 nodejs = nodejs_20; 60 }; 61 }) 62 yarnBuildHook 63 nodejs_20 64 # For yaml parsing 65 yq-go 66 ]; 67 doDist = false; 68 meta = { 69 description = "dashy"; 70 homepage = "https://dashy.to"; 71 license = lib.licenses.mit; 72 maintainers = [ lib.maintainers.therealgramdalf ]; 73 }; 74})