general usage :-P

This commit is contained in:
krizej 2024-08-29 23:13:04 +02:00
parent c3a9afe007
commit 9cad8c4165
10 changed files with 422 additions and 17 deletions

View file

@ -1,5 +1,63 @@
{
"nodes": {
"crane": {
"inputs": {
"nixpkgs": [
"zed",
"nixpkgs"
]
},
"locked": {
"lastModified": 1724537630,
"narHash": "sha256-gpqINM71zp3kw5XYwUXa84ZtPnCmLLnByuFoYesT1bY=",
"owner": "ipetkov",
"repo": "crane",
"rev": "3e08f4b1fc9aaede5dd511d8f5f4ef27501e49b0",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"fenix": {
"inputs": {
"nixpkgs": [
"zed",
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1724740262,
"narHash": "sha256-cpFasbzOTlwLi4fNas6hDznVUdCJn/lMLxi7MAMG6hg=",
"owner": "nix-community",
"repo": "fenix",
"rev": "703efdd9b5c6a7d5824afa348a24fbbf8ff226be",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-compat": {
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
@ -7,11 +65,11 @@
]
},
"locked": {
"lastModified": 1722203588,
"narHash": "sha256-91V5FMSQ4z9bkhTCf0f86Zjw0bh367daSf0mzCIW0vU=",
"lastModified": 1724435763,
"narHash": "sha256-UNky3lJNGQtUEXT2OY8gMxejakSWPTfWKvpFkpFlAfM=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "792757f643cedc13f02098d8ed506d82e19ec1da",
"rev": "c2cd2a52e02f1dfa1c88f95abeb89298d46023be",
"type": "github"
},
"original": {
@ -22,11 +80,11 @@
},
"nixos-hardware": {
"locked": {
"lastModified": 1723149858,
"narHash": "sha256-3u51s7jdhavmEL1ggtd8wqrTH2clTy5yaZmhLvAXTqc=",
"lastModified": 1724863014,
"narHash": "sha256-hRwyTHJaT8hCq4B6P17ppBQTbPZn0Gqc+fYEKWJpAb4=",
"owner": "nixos",
"repo": "nixos-hardware",
"rev": "107bb46eef1f05e86fc485ee8af9b637e5157988",
"rev": "c4e1b82a91c7b1b4c74aa39c573ddbf31a49d3e9",
"type": "github"
},
"original": {
@ -38,11 +96,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1722062969,
"narHash": "sha256-QOS0ykELUmPbrrUGmegAUlpmUFznDQeR4q7rFhl8eQg=",
"lastModified": 1724479785,
"narHash": "sha256-pP3Azj5d6M5nmG68Fu4JqZmdGt4S4vqI5f8te+E/FTw=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "b73c2221a46c13557b1b3be9c2070cc42cf01eb3",
"rev": "d0e1602ddde669d5beb01aec49d71a51937ed7be",
"type": "github"
},
"original": {
@ -52,13 +110,29 @@
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1724479785,
"narHash": "sha256-pP3Azj5d6M5nmG68Fu4JqZmdGt4S4vqI5f8te+E/FTw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d0e1602ddde669d5beb01aec49d71a51937ed7be",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nur": {
"locked": {
"lastModified": 1722287256,
"narHash": "sha256-A5I4ZAr+uuFS0uHMpH0YvgjMdhk5Hv1t/qDXjv1F7uk=",
"lastModified": 1724863915,
"narHash": "sha256-dMVmI1cEdpCmaSszxQT+YQ5qh2OZe2CZh3PiPInu/40=",
"owner": "nix-community",
"repo": "NUR",
"rev": "808f88bb6c63ee120d45a1cfb6c9f27f72a509b7",
"rev": "d20415149d0f983296f1d925123b4e212f004682",
"type": "github"
},
"original": {
@ -72,7 +146,46 @@
"home-manager": "home-manager",
"nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs",
"nur": "nur"
"nur": "nur",
"zed": "zed"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1724666781,
"narHash": "sha256-nOQDgjTDlWe0/+Ptf3o2p6UrznQFHnXBHRV1ZAsSpe8=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "095926ea6f008477a15a2ec6b0b8797e2e5be0e5",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
},
"zed": {
"inputs": {
"crane": "crane",
"fenix": "fenix",
"flake-compat": "flake-compat",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1724864015,
"narHash": "sha256-Qtf5aZVHpsM5HmJow5MS/HccxUrkl2KDGyUAUhaVqBU=",
"owner": "zed-industries",
"repo": "zed",
"rev": "c988ff8ed7ef2fd99c2fa51241320f628dfcf72e",
"type": "github"
},
"original": {
"owner": "zed-industries",
"repo": "zed",
"type": "github"
}
}
},

View file

@ -12,6 +12,8 @@
nur.url = "github:nix-community/NUR";
nixos-hardware.url = "github:nixos/nixos-hardware/master";
zed.url = "github:zed-industries/zed";
};
outputs = { ... } @ inputs: {

View file

@ -1,6 +1,7 @@
{ inputs, ... }:
{
"desktop" = inputs.nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs; };
modules = [
./desktop
../modules
@ -8,6 +9,7 @@
];
};
"laptop" = inputs.nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs; };
modules = [
./laptop
../modules
@ -15,6 +17,7 @@
];
};
"rpi" = inputs.nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs; };
modules = [
./rpi
../modules

View file

@ -1,4 +1,4 @@
{ config, pkgs, ... }:
{ inputs, config, pkgs, ... }:
{
imports = [
./hardware-configuration.nix
@ -42,6 +42,9 @@
cloc
viu
qbittorrent
godot_4
jetbrains.idea-community-bin
inputs.zed.packages.${system}.zed-editor
];
chuj = {

View file

@ -11,7 +11,8 @@ in {
home-manager.users.${user}.home.packages = with pkgs; [
pavucontrol
element-desktop
# element-desktop
schildichat-desktop
discord
libreoffice-qt
@ -20,4 +21,4 @@ in {
qimgv
];
};
}
}

View file

@ -5,7 +5,9 @@
ericw-tools-latest = callPackage ./ericw-tools-latest.nix {};
alacritty-sixel = callPackage ./alacritty-sixel.nix {};
i3status = prevPkgs.i3status.overrideAttrs (_: { patches = [ ../files/i3status.patch ]; });
vkquake = prevPkgs.vkquake.overrideAttrs (prev: {
schildichat-web = callPackage ./schildi/schildichat-web.nix {};
schildichat-desktop = callPackage ./schildi/schildichat-desktop.nix {};
vkquake_ = prevPkgs.vkquake.overrideAttrs (prev: {
version = "1.31.1";
src = pkgs.fetchFromGitHub {
inherit (prev.src) owner repo;

10
pkgs/schildi/pin.json Normal file
View file

@ -0,0 +1,10 @@
{
"version": "1.11.30-sc.2",
"rev": "v1.11.30-sc.2",
"srcHash": "1qb1fcr52gyzxndz3j77vn3ddwjpxwvicnh16c72zpzpfbbky7a5",
"webYarnHash": "0bg5vc7q8afqfpsaqqkczf9whbzici5d2bxj5cadhrlmlb27f8nx",
"jsSdkYarnHash": "0p1whh3pmqz170l542fiq3zgljl5daa9b96i59p3wvggnx7kny7j",
"reactSdkYarnHash": "02ysshiyjj3w00b628is9bd7i8qc3vc8kr1zam2dpj26lb9k5pdd",
"desktopYarnHash": "16pzmlwzf3z8mky3wb4azaiggigyfnpxmbq3irjp30ic6yhl50yw"
}

View file

@ -0,0 +1,122 @@
{ lib
, element-desktop # for seshat and keytar
, schildichat-web
, stdenv
, fetchFromGitHub
, makeWrapper
, makeDesktopItem
, copyDesktopItems
, fetchYarnDeps
, yarn
, nodejs
, prefetch-yarn-deps
, fixup-yarn-lock
, electron
, sqlcipher
}:
let
pinData = lib.importJSON ./pin.json;
executableName = "schildichat-desktop";
in
stdenv.mkDerivation rec {
pname = "schildichat-desktop";
inherit (pinData) version;
src = fetchFromGitHub {
owner = "SchildiChat";
repo = "schildichat-desktop";
inherit (pinData) rev;
sha256 = pinData.srcHash;
fetchSubmodules = true;
};
offlineCache = fetchYarnDeps {
yarnLock = src + "/element-desktop/yarn.lock";
sha256 = pinData.desktopYarnHash;
};
nativeBuildInputs = [ yarn fixup-yarn-lock prefetch-yarn-deps nodejs makeWrapper copyDesktopItems ];
inherit (element-desktop) seshat keytar;
configurePhase = ''
runHook preConfigure
export HOME=$(mktemp -d)
pushd element-desktop
yarn config --offline set yarn-offline-mirror $offlineCache
fixup-yarn-lock yarn.lock
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
rm -rf node_modules/matrix-seshat node_modules/keytar
ln -s $keytar node_modules/keytar
ln -s $seshat node_modules/matrix-seshat
patchShebangs node_modules/
popd
runHook postConfigure
'';
# Only affects unused scripts in $out/share/element/electron/scripts. Also
# breaks because there are some `node`-scripts with a `npx`-shebang and
# this shouldn't be in the closure just for unused scripts.
dontPatchShebangs = true;
buildPhase = ''
runHook preBuild
pushd element-desktop
yarn --offline run build:ts
yarn --offline run i18n
yarn --offline run build:res
popd
runHook postBuild
'';
installPhase = ''
runHook preInstall
# resources
mkdir -p "$out/share/element"
ln -s '${schildichat-web}' "$out/share/element/webapp"
mv element-desktop "$out/share/element/electron"
cp -r "$out/share/element/electron/res/img" "$out/share/element"
cp $out/share/element/electron/lib/i18n/strings/en_EN.json $out/share/element/electron/lib/i18n/strings/en-us.json
ln -s $out/share/element/electron/lib/i18n/strings/en{-us,}.json
# icons
for icon in $out/share/element/electron/build/icons/*.png; do
mkdir -p "$out/share/icons/hicolor/$(basename $icon .png)/apps"
ln -s "$icon" "$out/share/icons/hicolor/$(basename $icon .png)/apps/schildichat.png"
done
# executable wrapper
# LD_PRELOAD workaround for sqlcipher not found: https://github.com/matrix-org/seshat/issues/102
makeWrapper '${electron}/bin/electron' "$out/bin/${executableName}" \
--set LD_PRELOAD ${sqlcipher}/lib/libsqlcipher.so \
--add-flags "$out/share/element/electron" \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}"
runHook postInstall
'';
# The desktop item properties should be kept in sync with data from upstream:
# https://github.com/schildichat/element-desktop/blob/sc/package.json
desktopItems = [
(makeDesktopItem {
name = "schildichat-desktop";
exec = "${executableName} %u";
icon = "schildichat";
desktopName = "SchildiChat";
genericName = "Matrix Client";
comment = meta.description;
categories = [ "Network" "InstantMessaging" "Chat" ];
startupWMClass = "schildichat";
mimeTypes = [ "x-scheme-handler/element" ];
})
];
passthru.updateScript = ./update.sh;
meta = with lib; {
description = "Matrix client / Element Desktop fork";
homepage = "https://schildi.chat/";
changelog = "https://github.com/SchildiChat/schildichat-desktop/releases";
maintainers = teams.matrix.members ++ (with maintainers; [ kloenk yuka ]);
license = licenses.asl20;
platforms = platforms.all;
};
}

View file

@ -0,0 +1,105 @@
{ stdenv, lib
, fetchFromGitHub
, fetchYarnDeps
, nodejs_18
, yarn
, prefetch-yarn-deps
, fixup-yarn-lock
, writeText, jq, conf ? {}
}:
let
pinData = lib.importJSON ./pin.json;
noPhoningHome = {
disable_guests = true; # disable automatic guest account registration at matrix.org
};
configOverrides = writeText "element-config-overrides.json" (builtins.toJSON (noPhoningHome // conf));
in stdenv.mkDerivation rec {
pname = "schildichat-web";
inherit (pinData) version;
src = fetchFromGitHub {
owner = "SchildiChat";
repo = "schildichat-desktop";
inherit (pinData) rev;
sha256 = pinData.srcHash;
fetchSubmodules = true;
};
webOfflineCache = fetchYarnDeps {
yarnLock = src + "/element-web/yarn.lock";
sha256 = pinData.webYarnHash;
};
jsSdkOfflineCache = fetchYarnDeps {
yarnLock = src + "/matrix-js-sdk/yarn.lock";
sha256 = pinData.jsSdkYarnHash;
};
reactSdkOfflineCache = fetchYarnDeps {
yarnLock = src + "/matrix-react-sdk/yarn.lock";
sha256 = pinData.reactSdkYarnHash;
};
nativeBuildInputs = [ yarn fixup-yarn-lock prefetch-yarn-deps jq nodejs_18 ];
configurePhase = ''
runHook preConfigure
export HOME=$PWD/tmp
# with the update of openssl3, some key ciphers are not supported anymore
# this flag will allow those codecs again as a workaround
# see https://medium.com/the-node-js-collection/node-js-17-is-here-8dba1e14e382#5f07
# and https://github.com/vector-im/element-web/issues/21043
export NODE_OPTIONS=--openssl-legacy-provider
mkdir -p $HOME
pushd element-web
fixup-yarn-lock yarn.lock
yarn config --offline set yarn-offline-mirror $webOfflineCache
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive --ignore-engines
patchShebangs node_modules
rm -rf node_modules/matrix-react-sdk
ln -s $PWD/../matrix-react-sdk node_modules/
rm -rf node_modules/matrix-js-sdk
ln -s $PWD/../matrix-js-sdk node_modules/
popd
pushd matrix-js-sdk
fixup-yarn-lock yarn.lock
yarn config --offline set yarn-offline-mirror $jsSdkOfflineCache
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive --ignore-engines
patchShebangs node_modules
popd
pushd matrix-react-sdk
fixup-yarn-lock yarn.lock
yarn config --offline set yarn-offline-mirror $reactSdkOfflineCache
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive --ignore-engines
patchShebangs node_modules scripts
popd
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
pushd element-web
export VERSION=${version}
yarn build:res --offline
yarn build:module_system --offline
yarn build:bundle --offline
popd
runHook postBuild
'';
installPhase = ''
runHook preInstall
mv element-web/webapp $out
jq -s '.[0] * .[1]' "configs/sc/config.json" "${configOverrides}" > "$out/config.json"
runHook postInstall
'';
meta = with lib; {
description = "Matrix client / Element Web fork";
homepage = "https://schildi.chat/";
changelog = "https://github.com/SchildiChat/schildichat-desktop/releases";
maintainers = teams.matrix.members ++ (with maintainers; [ kloenk yuka ]);
license = licenses.asl20;
platforms = platforms.all;
};
}

44
pkgs/schildi/update.sh Normal file
View file

@ -0,0 +1,44 @@
#!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=../../../../../ -i bash -p nix wget prefetch-yarn-deps nix-prefetch-git jq
if [[ "$#" -gt 2 || "$1" == -* ]]; then
echo "Regenerates packaging data for the SchildiChat packages."
echo "Usage: $0 [git revision or tag] [version string override]"
exit 1
fi
rev="$1"
version="$2"
set -euo pipefail
if [ -z "$rev" ]; then
rev="$(wget -O- "https://api.github.com/repos/SchildiChat/schildichat-desktop/releases?per_page=1" | jq -r '.[0].tag_name')"
fi
if [ -z "$version" ]; then
# strip leading "v"
version="${rev#v}"
fi
src_data=$(nix-prefetch-git https://github.com/SchildiChat/schildichat-desktop --fetch-submodules --rev $rev)
src=$(echo $src_data | jq -r .path)
src_hash=$(echo $src_data | jq -r .sha256)
web_yarn_hash=$(prefetch-yarn-deps $src/element-web/yarn.lock)
desktop_yarn_hash=$(prefetch-yarn-deps $src/element-desktop/yarn.lock)
js_sdk_yarn_hash=$(prefetch-yarn-deps $src/matrix-js-sdk/yarn.lock)
react_sdk_yarn_hash=$(prefetch-yarn-deps $src/matrix-react-sdk/yarn.lock)
cat > pin.json << EOF
{
"version": "$version",
"rev": "$rev",
"srcHash": "$src_hash",
"webYarnHash": "$web_yarn_hash",
"jsSdkYarnHash": "$js_sdk_yarn_hash",
"reactSdkYarnHash": "$react_sdk_yarn_hash",
"desktopYarnHash": "$desktop_yarn_hash"
}
EOF