Compare commits
3
Commits
main
..
d8b6458928
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8b6458928 | ||
|
|
be7bffff67 | ||
|
|
a9055968e7 |
No files matched your search
Generated
+163
-50
@@ -7,11 +7,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1792526520,
|
||||
"narHash": "sha256-3hSJlv8mUVnZPMWK2+CM7a9O+nR6Z4mCh27NfLCmTPc=",
|
||||
"lastModified": 1773889306,
|
||||
"narHash": "sha256-PAqwnsBSI9SVC2QugvQ3xeYCB0otOwCacB1ueQj2tgw=",
|
||||
"owner": "nix-community",
|
||||
"repo": "disko",
|
||||
"rev": "cedd626e11b635470fa6f9fdb8ad79b0075dd7f9",
|
||||
"rev": "5ad85c82cc52264f4beddc934ba57f3789f28347",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -20,6 +20,58 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1747046372,
|
||||
"narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"home-manager": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
@@ -27,11 +79,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1794252721,
|
||||
"narHash": "sha256-sD1rhEjMghSyWSUG2xEOw+FOVd2wnoWwi/809w8fRkI=",
|
||||
"lastModified": 1774875815,
|
||||
"narHash": "sha256-PzqwM4njoB3aznqwPZUawD4uOcJeu7N6GBTJKg81EQ4=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "f1db7c474bb49babfe9d8def532939e0c7404327",
|
||||
"rev": "9340f51314713c83360bf72d75c8b404778ab5b1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -67,11 +119,11 @@
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1792739756,
|
||||
"narHash": "sha256-s0TeXWG5Ci75Y/Hzon0Z7NrN/fG773Rc54/z6oPFszQ=",
|
||||
"lastModified": 1769548169,
|
||||
"narHash": "sha256-03+JxvzmfwRu+5JafM0DLbxgHttOQZkUtDWBmeUkN8Y=",
|
||||
"owner": "nix-community",
|
||||
"repo": "impermanence",
|
||||
"rev": "fa627f4c8b8e92f58f58a73d99ee4e1304e64eb2",
|
||||
"rev": "7b1d382faf603b6d264f58627330f9faa5cba149",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -80,21 +132,66 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-vscode-extensions": {
|
||||
"madd": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1794202607,
|
||||
"narHash": "sha256-foUWdIx5HTEopoOHXzTy7uhbZYYl1BdjZKPQpkR+pgg=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nix-vscode-extensions",
|
||||
"rev": "934620178cf8eed2058484c24b5db62dbf4f08b1",
|
||||
"lastModified": 1754781336,
|
||||
"narHash": "sha256-EUavinU3psYqVDx7Cjdypsf4dUymdu1yawbwRYv6wbM=",
|
||||
"ref": "refs/heads/master",
|
||||
"rev": "d490b648ac5acb65aa24c8e8314c1a6fa9e2c0c1",
|
||||
"revCount": 8,
|
||||
"type": "git",
|
||||
"url": "https://git.bulthuis.dev/Jan/madd"
|
||||
},
|
||||
"original": {
|
||||
"type": "git",
|
||||
"url": "https://git.bulthuis.dev/Jan/madd"
|
||||
}
|
||||
},
|
||||
"nix-minecraft": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1751650156,
|
||||
"narHash": "sha256-1gIPVDf159TQlcVg3WQBHMZVn8RllHOa8eT7AJPj2IE=",
|
||||
"owner": "Jan-Bulthuis",
|
||||
"repo": "nix-minecraft",
|
||||
"rev": "d3b3779fd78bd55db24d25e896438b2b51cbb6cb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nix-vscode-extensions",
|
||||
"owner": "Jan-Bulthuis",
|
||||
"repo": "nix-minecraft",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-modpack": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1747559249,
|
||||
"narHash": "sha256-+ygKEGMVcXNklO4RDYSd5XzydDmQOZWcOcxYZf/PH1U=",
|
||||
"owner": "Jan-Bulthuis",
|
||||
"repo": "nix-modpack",
|
||||
"rev": "a093625c2847afc3ef257513161c7fe318c6be1c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "Jan-Bulthuis",
|
||||
"repo": "nix-modpack",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
@@ -116,43 +213,27 @@
|
||||
},
|
||||
"nixpkgs-stable": {
|
||||
"locked": {
|
||||
"lastModified": 1793865203,
|
||||
"narHash": "sha256-/cpdPHaySDIyCgZI6EWngiM6jK3YLUNzv1b7lTzy6Bk=",
|
||||
"lastModified": 1767313136,
|
||||
"narHash": "sha256-16KkgfdYqjaeRGBaYsNrhPRRENs0qzkQVUooNHtoy2w=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c56a87d8e41ce69bd2af57eb35dcc117a9dfca33",
|
||||
"rev": "ac62194c3917d5f474c1a844b6fd6da2db95077d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-26.05",
|
||||
"ref": "nixos-25.05",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1784564315,
|
||||
"narHash": "sha256-7OpsHHIZFUBLbeHNQ0oC40DZRQjsmGWodXge+OqgPgk=",
|
||||
"lastModified": 1775710090,
|
||||
"narHash": "sha256-ar3rofg+awPB8QXDaFJhJ2jJhu+KqN/PRCXeyuXR76E=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "0c2094806c9e542f31785ef3569ab9e900e3ce9c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "0c2094806c9e542f31785ef3569ab9e900e3ce9c",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1794042290,
|
||||
"narHash": "sha256-ziZn2PvCJE5JEEpqTdxXwJpPB+L3YqoCpTAMCzyaP3U=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "f4a03c008967841f2a0b3cb7c436fc6fc31671f6",
|
||||
"rev": "4c1018dae018162ec878d42fec712642d214fdfa",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -167,8 +248,10 @@
|
||||
"disko": "disko",
|
||||
"home-manager": "home-manager",
|
||||
"impermanence": "impermanence",
|
||||
"nix-vscode-extensions": "nix-vscode-extensions",
|
||||
"nixpkgs": "nixpkgs_3",
|
||||
"madd": "madd",
|
||||
"nix-minecraft": "nix-minecraft",
|
||||
"nix-modpack": "nix-modpack",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"nixpkgs-stable": "nixpkgs-stable",
|
||||
"secrets": "secrets",
|
||||
"sops-nix": "sops-nix"
|
||||
@@ -176,11 +259,11 @@
|
||||
},
|
||||
"secrets": {
|
||||
"locked": {
|
||||
"lastModified": 1795002280,
|
||||
"narHash": "sha256-PpeywbmyLrlliMSLvNCLT3L6Mmu5xHCGERrYuFIEM2s=",
|
||||
"lastModified": 1766822527,
|
||||
"narHash": "sha256-0qNxAxr7LQ8C6MjSxV2FkMSfdVmOVRq7Yz/wCea8plo=",
|
||||
"ref": "refs/heads/main",
|
||||
"rev": "0b61e4b871c3bb33d25fdb5493a995dfef14f8e5",
|
||||
"revCount": 24,
|
||||
"rev": "695e36891b5de248993845e1435df5e4116a26f2",
|
||||
"revCount": 21,
|
||||
"type": "git",
|
||||
"url": "ssh://gitea@git.bulthuis.dev/Jan/nixos-secrets"
|
||||
},
|
||||
@@ -196,11 +279,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1793995029,
|
||||
"narHash": "sha256-ZlE4BtMjWhfC6rFXLO9Qimn36Ene1INqCgKDDvazjhc=",
|
||||
"lastModified": 1774760784,
|
||||
"narHash": "sha256-D+tgywBHldTc0klWCIC49+6Zlp57Y4GGwxP1CqfxZrY=",
|
||||
"owner": "Mic92",
|
||||
"repo": "sops-nix",
|
||||
"rev": "89a234ce2daf6e568a7d4b4fe250afdd23d84e20",
|
||||
"rev": "8adb84861fe70e131d44e1e33c426a51e2e0bfa5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -208,6 +291,36 @@
|
||||
"repo": "sops-nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
inputs = {
|
||||
# General inputs
|
||||
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-26.05";
|
||||
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-25.05";
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
home-manager.url = "github:nix-community/home-manager";
|
||||
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
||||
@@ -18,18 +18,15 @@
|
||||
disko.inputs.nixpkgs.follows = "nixpkgs";
|
||||
impermanence.url = "github:nix-community/impermanence";
|
||||
|
||||
# VS Code extensions
|
||||
nix-vscode-extensions.url = "github:nix-community/nix-vscode-extensions";
|
||||
|
||||
# MADD
|
||||
# madd.url = "git+https://git.bulthuis.dev/Jan/madd";
|
||||
# madd.inputs.nixpkgs.follows = "nixpkgs";
|
||||
madd.url = "git+https://git.bulthuis.dev/Jan/madd";
|
||||
madd.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
# For Minecraft VM
|
||||
# nix-minecraft.url = "github:Jan-Bulthuis/nix-minecraft";
|
||||
# nix-minecraft.inputs.nixpkgs.follows = "nixpkgs";
|
||||
# nix-modpack.url = "github:Jan-Bulthuis/nix-modpack";
|
||||
# nix-modpack.inputs.nixpkgs.follows = "nixpkgs";
|
||||
nix-minecraft.url = "github:Jan-Bulthuis/nix-minecraft";
|
||||
nix-minecraft.inputs.nixpkgs.follows = "nixpkgs";
|
||||
nix-modpack.url = "github:Jan-Bulthuis/nix-modpack";
|
||||
nix-modpack.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs =
|
||||
|
||||
@@ -9,18 +9,6 @@ let
|
||||
|
||||
nixpkgs-config = {
|
||||
allowUnfree = true;
|
||||
|
||||
permittedInsecurePackages =
|
||||
let
|
||||
insecurePackages = [
|
||||
"electron-39.8.10"
|
||||
"pnpm-10.34.0"
|
||||
];
|
||||
in
|
||||
if builtins.length insecurePackages > 0 then
|
||||
lib.trace "Allowing [${lib.strings.join ", " insecurePackages}] which is/are insecure" insecurePackages
|
||||
else
|
||||
[ ];
|
||||
};
|
||||
|
||||
importDir =
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
{
|
||||
config,
|
||||
inputs,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
# State version
|
||||
system.stateVersion = "25.05";
|
||||
|
||||
# Machine hostname
|
||||
networking.hostName = "ws-home";
|
||||
|
||||
# Enabled modules
|
||||
modules = {
|
||||
profiles.server.enable = true;
|
||||
disko.profile = "ws-home";
|
||||
domain.enable = false;
|
||||
};
|
||||
|
||||
# Let the kernel handle router advertisements, so the route to the
|
||||
# Thread network advertised by the OTBR gets installed
|
||||
networking.dhcpcd.IPv6rs = false;
|
||||
boot.kernel.sysctl = {
|
||||
"net.ipv6.conf.default.accept_ra_rt_info_max_plen" = 64;
|
||||
"net.ipv6.conf.eno1.accept_ra" = 1;
|
||||
"net.ipv6.conf.eno1.accept_ra_rt_info_max_plen" = 64;
|
||||
};
|
||||
|
||||
# Matter controller
|
||||
services.matterjs-server = {
|
||||
enable = true;
|
||||
listenAddress = "::1";
|
||||
};
|
||||
modules.impermanence.directories = [
|
||||
"/var/lib/private/matterjs-server"
|
||||
"/var/lib/private/atticd"
|
||||
{
|
||||
directory = "/var/lib/hass";
|
||||
user = "hass";
|
||||
group = "hass";
|
||||
mode = "0700";
|
||||
}
|
||||
];
|
||||
systemd.tmpfiles.rules = [
|
||||
"d /var/lib/private 0700 root root -"
|
||||
"d /persist/system/var/lib/private 0700 root root -"
|
||||
];
|
||||
networking.firewall.allowedUDPPorts = [
|
||||
5353 # mDNS
|
||||
5540 # Matter
|
||||
];
|
||||
|
||||
# Home Assistant
|
||||
services.home-assistant = {
|
||||
enable = true;
|
||||
extraComponents = [
|
||||
"matter"
|
||||
"mobile_app"
|
||||
"otbr"
|
||||
"thread"
|
||||
];
|
||||
config = {
|
||||
homeassistant = { };
|
||||
mobile_app = { };
|
||||
http = {
|
||||
use_x_forwarded_for = true;
|
||||
# TODO: Narrow down to the address the internal gateway connects from
|
||||
trusted_proxies = [ "10.10.0.0/16" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
networking.firewall.allowedTCPPorts = [
|
||||
8123 # Home Assistant
|
||||
8080 # Attic
|
||||
];
|
||||
|
||||
# Attic binary cache, served as cache.ib.baksteeninc.net behind the reverse proxy
|
||||
sops.secrets."atticd/env".sopsFile = "${inputs.secrets}/secrets/ws-home.enc.yaml";
|
||||
services.atticd = {
|
||||
enable = true;
|
||||
environmentFile = config.sops.secrets."atticd/env".path;
|
||||
settings = {
|
||||
listen = "[::]:8080";
|
||||
api-endpoint = "https://cache.ib.baksteeninc.net/";
|
||||
compression.type = "zstd";
|
||||
garbage-collection = {
|
||||
interval = "12 hours";
|
||||
# Drop paths that have not been accessed for this long
|
||||
default-retention-period = "3 months";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Set up hardware
|
||||
imports = [
|
||||
./hardware-configuration.nix
|
||||
./seedbox.nix
|
||||
];
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
{ ... }:
|
||||
|
||||
{
|
||||
# Hardware configuration
|
||||
boot.initrd.availableKernelModules = [
|
||||
"xhci_pci"
|
||||
"ahci"
|
||||
"nvme"
|
||||
"usbhid"
|
||||
];
|
||||
boot.initrd.kernelModules = [ ];
|
||||
boot.kernelModules = [ ];
|
||||
boot.extraModulePackages = [ ];
|
||||
boot.zfs.forceImportRoot = false;
|
||||
hardware.cpu.intel.updateMicrocode = true;
|
||||
}
|
||||
@@ -1,235 +0,0 @@
|
||||
{
|
||||
config,
|
||||
inputs,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
# Torrent client confined to a VPN-only network namespace, plus a WebDAV share.
|
||||
# See seedbox.md.
|
||||
let
|
||||
netns = "seedbox";
|
||||
wgIf = "wg-seedbox";
|
||||
dataDir = "/var/lib/seedbox";
|
||||
downloadsDir = "${dataDir}/downloads";
|
||||
certDir = "${dataDir}/webui-tls";
|
||||
webuiPort = 8081;
|
||||
sharePort = 8091;
|
||||
inherit (config.networking) hostName;
|
||||
|
||||
secret = name: config.sops.secrets."seedbox/${name}".path;
|
||||
secretFile = "${inputs.secrets}/secrets/ws-home.enc.yaml";
|
||||
|
||||
user = config.services.qbittorrent.user;
|
||||
group = config.services.qbittorrent.group;
|
||||
inNetns = {
|
||||
NetworkNamespacePath = "/run/netns/${netns}";
|
||||
};
|
||||
netnsDeps = {
|
||||
bindsTo = [ "seedbox-netns.service" ];
|
||||
partOf = [ "seedbox-netns.service" ];
|
||||
after = [ "seedbox-netns.service" ];
|
||||
};
|
||||
in
|
||||
{
|
||||
sops.secrets = {
|
||||
"seedbox/wireguard".sopsFile = secretFile;
|
||||
"seedbox/port" = {
|
||||
sopsFile = secretFile;
|
||||
owner = user;
|
||||
};
|
||||
"seedbox/share-password" = {
|
||||
sopsFile = secretFile;
|
||||
owner = user;
|
||||
};
|
||||
};
|
||||
|
||||
modules.impermanence.directories = [
|
||||
{
|
||||
directory = dataDir;
|
||||
inherit user group;
|
||||
mode = "0750";
|
||||
}
|
||||
];
|
||||
systemd.tmpfiles.rules = [ "d ${downloadsDir} 0750 ${user} ${group} -" ];
|
||||
|
||||
boot.kernelModules = [ "tcp_bbr" ];
|
||||
|
||||
systemd.services.seedbox-netns = {
|
||||
description = "Network namespace for the seedbox";
|
||||
wants = [ "network-online.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
path = with pkgs; [
|
||||
iproute2
|
||||
procps
|
||||
wireguard-tools
|
||||
gnugrep
|
||||
gnused
|
||||
coreutils
|
||||
];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
RuntimeDirectory = "seedbox";
|
||||
RuntimeDirectoryPreserve = true;
|
||||
};
|
||||
script = ''
|
||||
set -euo pipefail
|
||||
conf=${secret "wireguard"}
|
||||
field() { grep -iE "^\s*$1\s*=" "$conf" | cut -d= -f2- | tr ',' '\n' | sed 's/ //g'; }
|
||||
|
||||
ip netns del ${netns} 2>/dev/null || true
|
||||
ip link del ${wgIf} 2>/dev/null || true
|
||||
|
||||
ip netns add ${netns}
|
||||
ip -n ${netns} link set lo up
|
||||
|
||||
# wg-quick strip requires a .conf file name
|
||||
stripped=$(grep -viE '^\s*(Address|DNS|MTU|Table|SaveConfig|(Pre|Post)(Up|Down))\s*=' "$conf")
|
||||
if ! grep -qi '^\s*PrivateKey' <<<"$stripped" || ! grep -qi '^\s*\[Peer\]' <<<"$stripped"; then
|
||||
echo "seedbox/wireguard has no PrivateKey or [Peer]" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ip link add ${wgIf} type wireguard
|
||||
wg setconf ${wgIf} <(printf '%s\n' "$stripped")
|
||||
if ! wg show ${wgIf} peers | grep -q .; then
|
||||
echo "WireGuard peer was not configured" >&2
|
||||
exit 1
|
||||
fi
|
||||
ip link set ${wgIf} netns ${netns}
|
||||
for addr in $(field Address); do
|
||||
ip -n ${netns} addr add "$addr" dev ${wgIf}
|
||||
done
|
||||
mtu=$(field MTU | head -1)
|
||||
ip -n ${netns} link set ${wgIf} mtu "''${mtu:-1420}" up
|
||||
ip -n ${netns} route add default dev ${wgIf}
|
||||
if field Address | grep -q ':'; then
|
||||
ip -n ${netns} -6 route add default dev ${wgIf}
|
||||
fi
|
||||
|
||||
# Faster TCP to distant peers
|
||||
ip netns exec ${netns} sysctl -q -w \
|
||||
net.ipv4.tcp_congestion_control=bbr \
|
||||
net.ipv4.tcp_wmem="4096 65536 16777216" \
|
||||
net.ipv4.tcp_rmem="4096 131072 16777216" \
|
||||
net.ipv4.tcp_slow_start_after_idle=0
|
||||
|
||||
field DNS | grep -v ':' | sed 's/^/nameserver /' > /run/seedbox/resolv.conf
|
||||
echo 'hosts: files dns' > /run/seedbox/nsswitch.conf
|
||||
'';
|
||||
preStop = ''
|
||||
ip netns del ${netns} || true
|
||||
'';
|
||||
};
|
||||
|
||||
services.qbittorrent = {
|
||||
enable = true;
|
||||
profileDir = dataDir;
|
||||
inherit webuiPort;
|
||||
extraArgs = [ "--confirm-legal-notice" ];
|
||||
};
|
||||
|
||||
systemd.services.qbittorrent = netnsDeps // {
|
||||
serviceConfig = inNetns // {
|
||||
# nscd would bypass the tunnel's DNS
|
||||
BindReadOnlyPaths = [
|
||||
"/run/seedbox/resolv.conf:/etc/resolv.conf"
|
||||
"/run/seedbox/nsswitch.conf:/etc/nsswitch.conf"
|
||||
];
|
||||
InaccessiblePaths = [ "-/run/nscd" ];
|
||||
ReadWritePaths = [ dataDir ];
|
||||
|
||||
ExecStartPre = pkgs.writeShellScript "seedbox-config" ''
|
||||
set -euo pipefail
|
||||
PATH=${
|
||||
lib.makeBinPath (
|
||||
with pkgs;
|
||||
[
|
||||
coreutils
|
||||
crudini
|
||||
openssl
|
||||
]
|
||||
)
|
||||
}
|
||||
cfg=${dataDir}/qBittorrent/config/qBittorrent.conf
|
||||
mkdir -p ${downloadsDir} "$(dirname "$cfg")"
|
||||
set_() { crudini --ini-options=nospace --set "$cfg" "$@"; }
|
||||
|
||||
if [ ! -f ${certDir}/cert.pem ]; then
|
||||
mkdir -p ${certDir}
|
||||
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes \
|
||||
-days 3650 -subj /CN=${hostName} -addext subjectAltName=DNS:${hostName},DNS:seedbox.bulthuis.dev \
|
||||
-keyout ${certDir}/key.pem -out ${certDir}/cert.pem
|
||||
chmod 600 ${certDir}/key.pem
|
||||
fi
|
||||
|
||||
if [ ! -f "$cfg" ]; then
|
||||
touch "$cfg"
|
||||
set_ BitTorrent 'Session\DefaultSavePath' ${downloadsDir}
|
||||
set_ BitTorrent 'Session\LSDEnabled' false
|
||||
set_ BitTorrent 'Session\QueueingSystemEnabled' false
|
||||
fi
|
||||
|
||||
set_ BitTorrent 'Session\Port' "$(tr -dc 0-9 < ${secret "port"})"
|
||||
set_ BitTorrent 'Session\Interface' ${wgIf}
|
||||
set_ BitTorrent 'Session\InterfaceName' ${wgIf}
|
||||
set_ Network PortForwardingEnabled false
|
||||
# qBittorrent 5 reads these from [WebUI], drop the old keys
|
||||
for k in Address Port HostHeaderValidation LocalHostAuth 'HTTPS\Enabled' 'HTTPS\CertificatePath' 'HTTPS\KeyPath'; do
|
||||
crudini --del "$cfg" Preferences "WebUI\\$k"
|
||||
done
|
||||
set_ WebUI 'Address' 127.0.0.1
|
||||
set_ WebUI 'Port' ${toString webuiPort}
|
||||
set_ WebUI 'HostHeaderValidation' false
|
||||
# Proxied clients appear as localhost, so they must not skip the login
|
||||
set_ WebUI 'LocalHostAuth' true
|
||||
set_ WebUI 'HTTPS\Enabled' true
|
||||
set_ WebUI 'HTTPS\CertificatePath' ${certDir}/cert.pem
|
||||
set_ WebUI 'HTTPS\KeyPath' ${certDir}/key.pem
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
systemd.sockets.seedbox-webui = {
|
||||
wantedBy = [ "sockets.target" ];
|
||||
listenStreams = [ (toString webuiPort) ];
|
||||
};
|
||||
systemd.services.seedbox-webui = netnsDeps // {
|
||||
requires = [ "qbittorrent.service" ];
|
||||
after = [ "qbittorrent.service" ];
|
||||
serviceConfig = inNetns // {
|
||||
ExecStart = "${pkgs.systemd}/lib/systemd/systemd-socket-proxyd 127.0.0.1:${toString webuiPort}";
|
||||
DynamicUser = true;
|
||||
PrivateTmp = true;
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.seedbox-share = {
|
||||
description = "Seedbox downloads share";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
wants = [ "network-online.target" ];
|
||||
serviceConfig = {
|
||||
User = user;
|
||||
Group = group;
|
||||
ProtectSystem = "strict";
|
||||
ProtectHome = true;
|
||||
PrivateTmp = true;
|
||||
NoNewPrivileges = true;
|
||||
ReadOnlyPaths = [ dataDir ];
|
||||
};
|
||||
script = ''
|
||||
export RCLONE_USER=seedbox
|
||||
RCLONE_PASS=$(cat ${secret "share-password"})
|
||||
export RCLONE_PASS
|
||||
exec ${lib.getExe pkgs.rclone} serve webdav ${downloadsDir} \
|
||||
--addr :${toString sharePort} --read-only --dir-cache-time 15s
|
||||
'';
|
||||
};
|
||||
networking.firewall.interfaces.eno1.allowedTCPPorts = [
|
||||
webuiPort
|
||||
sharePort
|
||||
];
|
||||
}
|
||||
@@ -27,16 +27,9 @@
|
||||
"wireshark"
|
||||
"podman"
|
||||
"libvirtd"
|
||||
"networkmanager"
|
||||
];
|
||||
};
|
||||
|
||||
# Steam Frame wireless adapter
|
||||
modules.steam-frame = {
|
||||
enable = true;
|
||||
regulatoryDomain = "NL";
|
||||
};
|
||||
|
||||
# Set up impermanence
|
||||
modules.impermanence = {
|
||||
enable = true;
|
||||
@@ -59,18 +52,6 @@
|
||||
|
||||
services.netbird = {
|
||||
enable = true;
|
||||
# package = pkgs.netbird.overrideAttrs (
|
||||
# final: prev: {
|
||||
# version = "0.66.3";
|
||||
# src = pkgs.fetchFromGitHub {
|
||||
# owner = "netbirdio";
|
||||
# repo = "netbird";
|
||||
# tag = "v${final.version}";
|
||||
# hash = "sha256-Cj9AcdWdHAfdBbqKAkwk3/Vy24XicjTZpmRXLYkyx3k=";
|
||||
# };
|
||||
# vendorHash = "sha256-vyf3zLTMtkmt+AXfCTRSPZ/TaJ8VP/5IzNbJwxQcfPs=";
|
||||
# }
|
||||
# );
|
||||
};
|
||||
|
||||
# SSH X11 forwarding
|
||||
@@ -85,25 +66,10 @@
|
||||
"passwd program" = "/run/wrappers/bin/passwd %u";
|
||||
"security" = "user";
|
||||
"client min protocol" = "NT1";
|
||||
"server min protocol" = "NT1";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# GStreamer
|
||||
environment.systemPackages = with pkgs; [
|
||||
gst_all_1.gstreamer
|
||||
gst_all_1.gst-plugins-base
|
||||
gst_all_1.gst-plugins-good
|
||||
gst_all_1.gst-plugins-bad
|
||||
gst_all_1.gst-plugins-ugly
|
||||
gst_all_1.gst-libav
|
||||
gst_all_1.gst-vaapi
|
||||
];
|
||||
environment.variables = {
|
||||
GST_PLUGIN_PATH = "/run/current-system/sw/lib/gstreamer-1.0/";
|
||||
};
|
||||
|
||||
# TODO: Remove once laptop is properly integrated into domain
|
||||
programs.ssh = {
|
||||
package = pkgs.openssh_gssapi;
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
boot.initrd.kernelModules = [ ];
|
||||
boot.kernelModules = [ "kvm-intel" ];
|
||||
boot.extraModulePackages = [ ];
|
||||
boot.zfs.forceImportRoot = false;
|
||||
hardware.cpu.intel.updateMicrocode = true;
|
||||
|
||||
# Filesystems
|
||||
|
||||
@@ -8,18 +8,6 @@
|
||||
|
||||
modules.profiles.jan.enable = true;
|
||||
|
||||
# Open Beat Saber OneClick links on the Steam Frame
|
||||
modules.beatsaber-oneclick = {
|
||||
enable = true;
|
||||
host = "steamos@frame.local";
|
||||
};
|
||||
|
||||
# Larger text while the desktop is streamed to the Steam Frame
|
||||
modules.steam-frame-desktop = {
|
||||
enable = true;
|
||||
streamingTextScale = 1.2;
|
||||
};
|
||||
|
||||
# home.packages = with pkgs; [
|
||||
# opencloud-desktop
|
||||
# code-nautilus
|
||||
@@ -57,8 +45,6 @@
|
||||
".SteamCloud"
|
||||
".thunderbird"
|
||||
".vscode"
|
||||
".vscode-shared"
|
||||
".var/app"
|
||||
".wine"
|
||||
".Wolfram"
|
||||
];
|
||||
|
||||
@@ -70,7 +70,6 @@ in
|
||||
mpris-label
|
||||
pip-on-top
|
||||
rounded-window-corners-reborn
|
||||
caffeine
|
||||
]);
|
||||
|
||||
# Set up gnome terminal as changing the default terminal is a pain
|
||||
|
||||
@@ -28,18 +28,6 @@ in
|
||||
default = [ ];
|
||||
description = "Paths to globally ignore";
|
||||
};
|
||||
|
||||
signingKey = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = "Path to the SSH public key used to sign commits and tags.";
|
||||
};
|
||||
|
||||
allowedSigners = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = "Trusted signers for verifying SSH signatures, as \"<email> <public key>\" lines.";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
@@ -51,7 +39,7 @@ in
|
||||
programs.git = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
extraConfig = {
|
||||
pull = {
|
||||
rebase = false;
|
||||
};
|
||||
@@ -59,17 +47,7 @@ in
|
||||
|
||||
settings.user.name = cfg.user;
|
||||
settings.user.email = cfg.email;
|
||||
ignores = cfg.ignores;
|
||||
|
||||
signing = mkIf (cfg.signingKey != null) {
|
||||
format = "ssh";
|
||||
key = cfg.signingKey;
|
||||
signByDefault = true; # commit.gpgsign and tag.gpgSign
|
||||
};
|
||||
|
||||
settings.gpg.ssh.allowedSignersFile = mkIf (cfg.allowedSigners != [ ]) (
|
||||
toString (pkgs.writeText "git-allowed-signers" (concatLines cfg.allowedSigners))
|
||||
);
|
||||
# ignores = cfg.ignores;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -18,7 +18,7 @@ in
|
||||
# Development packages
|
||||
home.packages = with pkgs; [
|
||||
nix-tree
|
||||
nixfmt
|
||||
nixfmt-rfc-style
|
||||
nixd
|
||||
];
|
||||
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.modules.beatsaber-oneclick;
|
||||
in
|
||||
{
|
||||
options.modules.beatsaber-oneclick = {
|
||||
enable = mkEnableOption "forwarding Beat Saber OneClick links to a Steam Frame";
|
||||
|
||||
host = mkOption {
|
||||
type = types.str;
|
||||
example = "steamos@frame.local";
|
||||
description = "SSH destination of the Steam Frame. Needs key auth, as there is no terminal to ask for a password.";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
# The schemes BSManager handles on the Frame. Registering them here makes
|
||||
# browsers on this machine hand the links to the Frame.
|
||||
xdg.desktopEntries.beatsaber-oneclick = {
|
||||
name = "Beat Saber OneClick (Steam Frame)";
|
||||
comment = "Install Beat Saber maps and playlists on the Steam Frame";
|
||||
type = "Application";
|
||||
exec = "${pkgs.beatsaber-oneclick}/bin/beatsaber-oneclick ${escapeShellArg cfg.host} %u";
|
||||
terminal = false;
|
||||
noDisplay = true;
|
||||
mimeType = [
|
||||
"x-scheme-handler/beatsaver"
|
||||
"x-scheme-handler/bsplaylist"
|
||||
"x-scheme-handler/web+bsmap"
|
||||
"x-scheme-handler/modelsaber"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.modules.steam-frame-desktop;
|
||||
|
||||
log = "${config.xdg.dataHome}/Steam/logs/streaming_log.txt";
|
||||
|
||||
setScale = scale: "${pkgs.glib}/bin/gsettings set org.gnome.desktop.interface text-scaling-factor ${toString scale}";
|
||||
|
||||
# Follows Steam's streaming log, which marks when a desktop stream starts and stops
|
||||
# (Remote Play "Connect" on the Frame, or the desktop view in PC VR)
|
||||
watcher = pkgs.writeShellScript "steam-frame-desktop-scale" ''
|
||||
${pkgs.coreutils}/bin/tail -n 0 -F ${escapeShellArg log} 2>/dev/null | while IFS= read -r line; do
|
||||
case "$line" in
|
||||
*">>> Starting desktop stream"*)
|
||||
${setScale cfg.streamingTextScale} ;;
|
||||
# Also reset when Steam restarts, in case it quit mid-stream
|
||||
*">>> Stopped desktop stream"* | *"Client version:"*)
|
||||
${setScale cfg.normalTextScale} ;;
|
||||
esac
|
||||
done
|
||||
'';
|
||||
in
|
||||
{
|
||||
options.modules.steam-frame-desktop = {
|
||||
enable = mkEnableOption "larger text while the desktop is streamed to a Steam Frame";
|
||||
|
||||
streamingTextScale = mkOption {
|
||||
type = types.float;
|
||||
default = 1.44;
|
||||
description = "GNOME text scaling factor while the desktop is being streamed.";
|
||||
};
|
||||
|
||||
normalTextScale = mkOption {
|
||||
type = types.float;
|
||||
default = 1.0;
|
||||
description = "GNOME text scaling factor otherwise.";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.user.services.steam-frame-desktop-scale = {
|
||||
Unit = {
|
||||
Description = "Scale text up while the desktop is streamed to a Steam Frame";
|
||||
PartOf = [ "graphical-session.target" ];
|
||||
After = [ "graphical-session.target" ];
|
||||
};
|
||||
Service = {
|
||||
ExecStart = "${watcher}";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
Install.WantedBy = [ "graphical-session.target" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -21,7 +21,6 @@ in
|
||||
};
|
||||
modules.git.ignores = [
|
||||
".direnv"
|
||||
".envrc"
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -16,5 +16,8 @@ in
|
||||
systemd-boot.editor = false;
|
||||
efi.canTouchEfiVariables = true;
|
||||
};
|
||||
|
||||
# Initrd
|
||||
boot.initrd.systemd.enable = true;
|
||||
};
|
||||
}
|
||||
@@ -17,10 +17,7 @@ in
|
||||
# TODO: Move to nvidia module
|
||||
hardware.nvidia = {
|
||||
open = false;
|
||||
powerManagement.enable = true;
|
||||
prime = {
|
||||
offload.enable = true;
|
||||
offload.enableOffloadCmd = true;
|
||||
intelBusId = "PCI:0@0:2:0";
|
||||
nvidiaBusId = "PCI:1@0:0:0";
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ in
|
||||
options.modules.impermanence = {
|
||||
enable = mkEnableOption "Impermanence";
|
||||
directories = mkOption {
|
||||
type = types.listOf (types.either types.str types.attrs);
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
Directories that should be stored in persistent storage.
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.modules.steam-frame;
|
||||
kernel = config.boot.kernelPackages.kernel;
|
||||
|
||||
# Out-of-tree rtw89 driver, as the in-tree rtw89_8852cu driver needs Linux 7.0+,
|
||||
# which ZFS does not support yet
|
||||
rtw89 = pkgs.stdenv.mkDerivation {
|
||||
pname = "rtw89-morrownr";
|
||||
version = "0-unstable-2026-11-09-${kernel.version}";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "morrownr";
|
||||
repo = "rtw89";
|
||||
rev = "f2ce66eda6277e5505d5914a8a08454440518702";
|
||||
hash = "sha256-u2sJ/1tvDM6MloulU7l3w9eLCc2GZqOBebI7/eQbeC8=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = kernel.moduleBuildDependencies;
|
||||
makeFlags = kernel.commonMakeFlags ++ [
|
||||
"KDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
|
||||
];
|
||||
buildFlags = [ "modules" ];
|
||||
|
||||
# Install through Kbuild so the modules are signed (produces the .ko.cer files)
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
local flagsArray=()
|
||||
concatTo flagsArray makeFlags
|
||||
make "''${flagsArray[@]}" -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build M=$PWD \
|
||||
modules_install INSTALL_MOD_PATH=$out INSTALL_MOD_DIR=updates/rtw89
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta.platforms = platforms.linux;
|
||||
};
|
||||
in
|
||||
{
|
||||
options.modules.steam-frame = {
|
||||
enable = mkEnableOption "Steam Frame wireless streaming adapter";
|
||||
|
||||
regulatoryDomain = mkOption {
|
||||
type = types.str;
|
||||
description = "Country code to use for Wi-Fi, needed to unlock the 6 GHz band.";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
# Driver for the adapter (Realtek RTL8832CU, 28de:2432)
|
||||
# Firmware comes from linux-firmware (hardware.enableRedistributableFirmware)
|
||||
boot.extraModulePackages = [ rtw89 ];
|
||||
boot.extraModprobeConfig = ''
|
||||
options cfg80211 ieee80211_regdom=${cfg.regulatoryDomain}
|
||||
|
||||
# The adapter tends to stall when it enters power saving
|
||||
options rtw89_core_git disable_ps_mode=y
|
||||
|
||||
# Prevent the in-tree drivers from claiming the adapter
|
||||
blacklist rtw89_core
|
||||
blacklist rtw89_usb
|
||||
blacklist rtw89_8852c
|
||||
blacklist rtw89_8852cu
|
||||
'';
|
||||
|
||||
# Never let the adapter doze. In power save the Frame (the access point) buffers
|
||||
# traffic for the PC until it wakes up, which stalls streams towards the PC
|
||||
# such as spectating. This overrides the global wifi.powersave for this driver only.
|
||||
networking.networkmanager.settings."connection-steam-frame" = {
|
||||
match-device = "driver:rtw89_8852cu_git";
|
||||
"wifi.powersave" = 2;
|
||||
};
|
||||
|
||||
# Udev rules for Valve devices
|
||||
hardware.steam-hardware.enable = true;
|
||||
|
||||
# Streaming ports
|
||||
networking.firewall = {
|
||||
allowedTCPPorts = [ 27036 ];
|
||||
allowedUDPPortRanges = [
|
||||
{
|
||||
from = 10400;
|
||||
to = 10401;
|
||||
}
|
||||
{
|
||||
from = 27031;
|
||||
to = 27036;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
environment.systemPackages = [ pkgs.iw ];
|
||||
};
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
# Forwards a Beat Saber OneClick link to the Steam Frame, where BSManager downloads it,
|
||||
# and keeps a desktop notification up to date until the install is done.
|
||||
# Usage: beatsaber-oneclick <ssh-host> <url>
|
||||
# $remote_script (remote.sh) is set by the package.
|
||||
|
||||
host=${1:?usage: beatsaber-oneclick <ssh-host> <url>}
|
||||
url=${2:?usage: beatsaber-oneclick <ssh-host> <url>}
|
||||
api=https://api.beatsaver.com
|
||||
|
||||
# One notification, updated in place
|
||||
notification_id=
|
||||
notify() {
|
||||
local id
|
||||
if id=$(notify-send --print-id ${notification_id:+--replace-id="$notification_id"} \
|
||||
--app-name="Beat Saber OneClick" --icon=input-gaming "$@"); then
|
||||
notification_id=$id
|
||||
fi
|
||||
}
|
||||
|
||||
# Only forward the OneClick schemes, and only plain URL characters, since the URL
|
||||
# ends up in a remote shell command line.
|
||||
if [[ ! $url =~ ^(beatsaver|bsplaylist|web\+bsmap|modelsaber):// ]] ||
|
||||
[[ ! $url =~ ^[A-Za-z0-9+.:/?#\&=%_~@!,\;-]+$ ]]; then
|
||||
notify --urgency=critical "Not a OneClick link" "$url"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fetch() {
|
||||
curl -sfL --max-time 20 "$@"
|
||||
}
|
||||
|
||||
# Look up what the link installs, to know which map folders to watch for. If that
|
||||
# fails, the link is still sent, just without tracking.
|
||||
ids=()
|
||||
label=$url
|
||||
playlist=
|
||||
case $url in
|
||||
beatsaver://* | web+bsmap://*)
|
||||
ref=${url#*://}
|
||||
ref=${ref%%[/?#]*}
|
||||
if [[ $url == beatsaver://* ]]; then
|
||||
map=$(fetch "$api/maps/id/$ref") || map=
|
||||
else
|
||||
map=$(fetch "$api/maps/hash/$ref") || map=
|
||||
fi
|
||||
if [[ -n $map ]]; then
|
||||
ids=("$(jq -r '.id | ascii_downcase' <<<"$map")")
|
||||
label=$(jq -r '"\(.metadata.songName) – \(.metadata.levelAuthorName)"' <<<"$map")
|
||||
fi
|
||||
;;
|
||||
bsplaylist://playlist/*)
|
||||
playlist=1
|
||||
label="Playlist"
|
||||
if bplist=$(fetch "${url#bsplaylist://playlist/}"); then
|
||||
label=$(jq -r '.playlistTitle // "Playlist"' <<<"$bplist")
|
||||
# Entries with a key need no lookup; resolve the rest by hash, 50 at a time
|
||||
mapfile -t ids < <(jq -r '.songs[] | .key // empty | ascii_downcase' <<<"$bplist")
|
||||
mapfile -t hashes < <(jq -r '.songs[] | select(.key == null) | .hash // empty | ascii_downcase' <<<"$bplist")
|
||||
for ((i = 0; i < ${#hashes[@]}; i += 50)); do
|
||||
batch=$(
|
||||
IFS=,
|
||||
echo "${hashes[*]:i:50}"
|
||||
)
|
||||
if found=$(fetch "$api/maps/hash/$batch"); then
|
||||
# A single hash returns the map itself instead of a hash → map object
|
||||
mapfile -t -O "${#ids[@]}" ids < <(jq -r 'if has("id") then .id else (.[] | select(. != null) | .id) end | ascii_downcase' <<<"$found")
|
||||
fi
|
||||
done
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
notify "Sending to Steam Frame…" "$label"
|
||||
|
||||
total=${#ids[@]}
|
||||
done_count=0
|
||||
new=0
|
||||
already=0
|
||||
missing=0
|
||||
last_error=
|
||||
stderr_file=$(mktemp)
|
||||
trap 'rm -f "$stderr_file"' EXIT
|
||||
|
||||
exec {events}< <(ssh -T -o BatchMode=yes -o ConnectTimeout=5 "$host" \
|
||||
bash -s -- "$(printf '%q' "$url")" "${ids[@]}" <"$remote_script" 2>"$stderr_file")
|
||||
ssh_pid=$!
|
||||
|
||||
while IFS= read -r -u "$events" event; do
|
||||
case $event in
|
||||
received)
|
||||
notify "Downloading on Steam Frame…" "$label"
|
||||
;;
|
||||
"done "*)
|
||||
done_count=$((done_count + 1))
|
||||
if ((total > 1)); then
|
||||
notify "Downloading on Steam Frame… $done_count/$total" "$label"
|
||||
fi
|
||||
;;
|
||||
"error "*)
|
||||
last_error=${event#error }
|
||||
;;
|
||||
"result "*" new") new=$((new + 1)) ;;
|
||||
"result "*" already") already=$((already + 1)) ;;
|
||||
"result "*" missing") missing=$((missing + 1)) ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if ! wait "$ssh_pid"; then
|
||||
err=$(tr -d '\r' <"$stderr_file" | grep -v 'X11 forwarding' || true)
|
||||
notify --urgency=critical "Couldn't send to Steam Frame" "${err:-ssh failed}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
failure_hint=${last_error:-BSManager didn\'t finish within 2 minutes. Check it on the Frame.}
|
||||
|
||||
if ((total == 0)); then
|
||||
notify "Sent to Steam Frame" "$label"$'\n(Not tracked: couldn\'t look it up on BeatSaver.)'
|
||||
elif [[ -z $playlist ]]; then
|
||||
if ((new > 0)); then
|
||||
notify "Installed on Steam Frame" "$label"
|
||||
elif ((already > 0)); then
|
||||
notify "Already on Steam Frame" "$label"
|
||||
else
|
||||
notify --urgency=critical "Not installed on Steam Frame" "$label"$'\n'"$failure_hint"
|
||||
fi
|
||||
else
|
||||
summary="$label: $new new, $already already there"
|
||||
if ((missing > 0)); then
|
||||
notify --urgency=critical "Playlist partly installed on Steam Frame" \
|
||||
"$summary, $missing failed"$'\n'"$failure_hint"
|
||||
else
|
||||
notify "Playlist installed on Steam Frame" "$summary"
|
||||
fi
|
||||
fi
|
||||
@@ -1,25 +0,0 @@
|
||||
{
|
||||
writeShellApplication,
|
||||
openssh,
|
||||
libnotify,
|
||||
curl,
|
||||
jq,
|
||||
}:
|
||||
|
||||
# Forwards Beat Saber OneClick links (BeatSaver, BeatLeader, ScoreSaber, playlists)
|
||||
# to a Steam Frame over SSH and opens them there, so BSManager on the Frame does the
|
||||
# download, and shows the install progress as a notification.
|
||||
# Usage: beatsaber-oneclick <ssh-host> <url>
|
||||
writeShellApplication {
|
||||
name = "beatsaber-oneclick";
|
||||
runtimeInputs = [
|
||||
openssh
|
||||
libnotify
|
||||
curl
|
||||
jq
|
||||
];
|
||||
text = ''
|
||||
remote_script=${./remote.sh}
|
||||
''
|
||||
+ builtins.readFile ./beatsaber-oneclick.sh;
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Runs on the Steam Frame (piped over SSH): opens a OneClick link in the graphical
|
||||
# session, so the Frame's own handler (BSManager) downloads and installs it.
|
||||
#
|
||||
# Usage: remote.sh <url> [<beatsaver map id>...]
|
||||
#
|
||||
# With map ids, it then watches BSManager's log and map folders until those maps are
|
||||
# installed, and reports on stdout, one event per line:
|
||||
# received BSManager got the link
|
||||
# downloading <id> BSManager started downloading a map
|
||||
# done <id> the map's folder was (re)written and is complete
|
||||
# error <message> BSManager logged an error (may be unrelated)
|
||||
# result <id> new|already|missing
|
||||
set -euo pipefail
|
||||
|
||||
url=$1
|
||||
shift
|
||||
ids=("$@")
|
||||
uid=$(id -u)
|
||||
|
||||
# BSManager's default locations (installation folder not changed)
|
||||
bsm=$HOME/.local/share/BSManager
|
||||
logs=$HOME/.config/bs-manager/logs
|
||||
|
||||
# Give up when nothing has happened for this long (BSManager may need to start first)
|
||||
timeout=120
|
||||
# With maps that were already installed, finish once BSManager is quiet for this long
|
||||
quiet=10
|
||||
|
||||
for id in "${ids[@]}"; do
|
||||
if [[ ! $id =~ ^[0-9a-f]+$ ]]; then
|
||||
echo "Invalid map id: $id" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# An SSH session has no display. Borrow the display variables from a process in
|
||||
# the graphical session, preferring the Steam client.
|
||||
session_env() {
|
||||
local pid env
|
||||
for pid in $(pgrep -u "$uid" -x steam || true) $(pgrep -u "$uid"); do
|
||||
env=$(tr '\0' '\n' <"/proc/$pid/environ" 2>/dev/null) || continue
|
||||
if grep -qE '^(DISPLAY|WAYLAND_DISPLAY)=' <<<"$env"; then
|
||||
printf '%s\n' "$env"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
if ! env=$(session_env); then
|
||||
echo "No graphical session found on the Frame (is it signed in?)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while IFS= read -r line; do
|
||||
export "${line?}"
|
||||
done < <(grep -E '^(DISPLAY|WAYLAND_DISPLAY|XAUTHORITY|XDG_CURRENT_DESKTOP|XDG_SESSION_TYPE|DBUS_SESSION_BUS_ADDRESS)=' <<<"$env")
|
||||
|
||||
opener=
|
||||
for candidate in gio xdg-open kde-open; do
|
||||
if command -v "$candidate" >/dev/null; then
|
||||
opener=$candidate
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ -z $opener ]]; then
|
||||
echo "No gio, xdg-open or kde-open on the Frame" >&2
|
||||
exit 1
|
||||
fi
|
||||
open_cmd=("$opener")
|
||||
[[ $opener == gio ]] && open_cmd+=(open)
|
||||
|
||||
map_dirs=("$bsm"/BSInstances/*/"Beat Saber_Data"/CustomLevels "$bsm"/SharedContent/SharedMaps/CustomLevels)
|
||||
|
||||
# Prints "<newest change time> <total size>" over a map's folders in all instances,
|
||||
# or "none". Change time (not mtime), as extracting may keep the zip's mtimes.
|
||||
map_state() {
|
||||
local d f t s newest=0 size=0 found=
|
||||
for d in "${map_dirs[@]}"; do
|
||||
for f in "$d/$1 ("*; do
|
||||
[[ -d $f ]] || continue
|
||||
found=1
|
||||
t=$(find "$f" -printf '%C@\n' | sort -n | tail -n1)
|
||||
t=${t%.*}
|
||||
((t > newest)) && newest=$t
|
||||
s=$(du -sb "$f" | cut -f1)
|
||||
size=$((size + s))
|
||||
done
|
||||
done
|
||||
if [[ -n $found ]]; then echo "$newest $size"; else echo none; fi
|
||||
}
|
||||
|
||||
# BSManager log lines written since we started. Continuation lines (stack traces)
|
||||
# don't start with a timestamp and are left out.
|
||||
log_since_start() {
|
||||
find "$logs" -name '*.log' -newermt "@$start" -print0 2>/dev/null |
|
||||
xargs -0r cat |
|
||||
awk -v s="[$start_log" 'substr($0, 1, 20) >= s'
|
||||
}
|
||||
|
||||
declare -A pre state prev
|
||||
for id in "${ids[@]}"; do
|
||||
pre[$id]=$(map_state "$id")
|
||||
state[$id]=pending
|
||||
prev[$id]=
|
||||
done
|
||||
|
||||
start=$(date +%s)
|
||||
start_log=$(date -d "@$start" '+%Y-%m-%d %H:%M:%S')
|
||||
|
||||
# gio comes first: xdg-open (generic mode) mangles the quoted path in BSManager's Exec line.
|
||||
# Run it in its own scope, detached from this SSH session: if BSManager isn't running
|
||||
# yet, the handler starts it, and it must outlive the connection. Output goes to the
|
||||
# journal: journalctl --user -t beatsaber-oneclick
|
||||
systemd-run --user --scope --collect --quiet \
|
||||
setsid -f systemd-cat -t beatsaber-oneclick "${open_cmd[@]}" "$url" \
|
||||
</dev/null >/dev/null 2>&1
|
||||
|
||||
((${#ids[@]} > 0)) || exit 0
|
||||
|
||||
received=
|
||||
errors_seen=0
|
||||
last_activity=$start
|
||||
while :; do
|
||||
sleep 1
|
||||
now=$(date +%s)
|
||||
lines=$(log_since_start)
|
||||
|
||||
if [[ -z $received ]] && grep -q 'DEEP-LINK RECEIVED' <<<"$lines"; then
|
||||
received=1
|
||||
last_activity=$now
|
||||
echo received
|
||||
fi
|
||||
|
||||
mapfile -t errors < <(grep -F '[error]' <<<"$lines" || true)
|
||||
for err in "${errors[@]:errors_seen}"; do
|
||||
echo "error ${err#*\[error\] }"
|
||||
done
|
||||
errors_seen=${#errors[@]}
|
||||
|
||||
waiting=0
|
||||
all_done=1
|
||||
for id in "${ids[@]}"; do
|
||||
[[ ${state[$id]} == installed ]] && continue
|
||||
all_done=
|
||||
|
||||
if [[ ${state[$id]} == pending ]] && grep -qF " $id https://" <<<"$lines"; then
|
||||
state[$id]=downloading
|
||||
last_activity=$now
|
||||
echo "downloading $id"
|
||||
fi
|
||||
|
||||
# Done once the folder changed since we started and stayed the same for a second
|
||||
cur=$(map_state "$id")
|
||||
if [[ $cur != none ]] && ((${cur%% *} >= start)); then
|
||||
if [[ $cur == "${prev[$id]}" ]]; then
|
||||
state[$id]=installed
|
||||
last_activity=$now
|
||||
echo "done $id"
|
||||
continue
|
||||
fi
|
||||
prev[$id]=$cur
|
||||
last_activity=$now
|
||||
fi
|
||||
|
||||
# Maps that weren't installed yet, or are being downloaded, are worth waiting for
|
||||
if [[ ${state[$id]} == downloading || ${pre[$id]} == none ]]; then
|
||||
waiting=$((waiting + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
[[ -n $all_done ]] && break
|
||||
[[ -n $received ]] && ((waiting == 0 && now - last_activity >= quiet)) && break
|
||||
((now - last_activity >= timeout)) && break
|
||||
done
|
||||
|
||||
for id in "${ids[@]}"; do
|
||||
if [[ ${state[$id]} == installed ]]; then
|
||||
echo "result $id new"
|
||||
elif [[ ${pre[$id]} != none ]]; then
|
||||
echo "result $id already"
|
||||
else
|
||||
echo "result $id missing"
|
||||
fi
|
||||
done
|
||||
@@ -1,82 +0,0 @@
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
# Render node of the GPU the OpenXR runtime uses, for hybrid graphics laptops
|
||||
# (e.g. "/dev/dri/by-path/pci-0000:01:00.0-render"). Only NVIDIA is supported.
|
||||
nvidiaRenderNode ? null,
|
||||
...
|
||||
}:
|
||||
|
||||
# Google Chrome with WebXR over OpenXR. nixpkgs' Chromium sets checkout_openxr = false,
|
||||
# so it is built without the OpenXR backend.
|
||||
let
|
||||
chrome = pkgs.google-chrome;
|
||||
|
||||
flags = [
|
||||
"--enable-features=OpenXR"
|
||||
# The broker reports the wrong pid to SteamVR, which then fails xrCreateInstance
|
||||
"--disable-seccomp-filter-sandbox"
|
||||
"--ozone-platform=wayland"
|
||||
"--use-angle=gl"
|
||||
]
|
||||
++ lib.optionals (nvidiaRenderNode != null) [
|
||||
# The compositor runs on the integrated GPU and can't import NVIDIA buffers,
|
||||
# so the window is composited in software while WebGL and WebXR stay on NVIDIA
|
||||
"--render-node-override=${nvidiaRenderNode}"
|
||||
"--disable-gpu-compositing"
|
||||
];
|
||||
|
||||
desktopItem = pkgs.makeDesktopItem {
|
||||
name = "chrome-xr";
|
||||
exec = "chrome-xr %U";
|
||||
icon = "google-chrome";
|
||||
desktopName = "Chrome XR";
|
||||
genericName = "WebXR Browser";
|
||||
comment = "Google Chrome with WebXR through OpenXR";
|
||||
categories = [
|
||||
"Network"
|
||||
"WebBrowser"
|
||||
];
|
||||
mimeTypes = [
|
||||
"text/html"
|
||||
"x-scheme-handler/http"
|
||||
"x-scheme-handler/https"
|
||||
];
|
||||
};
|
||||
in
|
||||
pkgs.symlinkJoin {
|
||||
name = "chrome-xr-${chrome.version}";
|
||||
|
||||
paths = [
|
||||
(pkgs.writeShellScriptBin "chrome-xr" ''
|
||||
# SteamVR's vrclient.so needs these, which NixOS doesn't provide globally
|
||||
export LD_LIBRARY_PATH=${
|
||||
lib.makeLibraryPath [
|
||||
pkgs.libuuid
|
||||
pkgs.libglvnd
|
||||
]
|
||||
}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
|
||||
|
||||
${lib.optionalString (nvidiaRenderNode != null) ''
|
||||
# Render on the NVIDIA GPU, which the OpenXR runtime also uses
|
||||
export __NV_PRIME_RENDER_OFFLOAD=1
|
||||
export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
|
||||
export __GLX_VENDOR_LIBRARY_NAME=nvidia
|
||||
export __EGL_VENDOR_LIBRARY_FILENAMES=/run/opengl-driver/share/glvnd/egl_vendor.d/10_nvidia.json
|
||||
export __VK_LAYER_NV_optimus=NVIDIA_only
|
||||
''}
|
||||
|
||||
# Separate profile, as the seccomp sandbox is disabled
|
||||
exec ${chrome}/bin/google-chrome-stable \
|
||||
${lib.escapeShellArgs flags} \
|
||||
--user-data-dir="''${XDG_CONFIG_HOME:-$HOME/.config}/chrome-xr" \
|
||||
"$@"
|
||||
'')
|
||||
desktopItem
|
||||
];
|
||||
|
||||
meta = chrome.meta // {
|
||||
description = "Google Chrome with WebXR through OpenXR";
|
||||
mainProgram = "chrome-xr";
|
||||
};
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
fetchFromGitHub,
|
||||
rustPlatform,
|
||||
helix,
|
||||
helix-unwrapped,
|
||||
tree-sitter,
|
||||
pkgs,
|
||||
}:
|
||||
|
||||
# Helix from git, built with nixpkgs' packaging instead of the upstream flake. The
|
||||
# flake fetches every tree-sitter grammar without a hash at evaluation time. Here
|
||||
# they are pinned in grammars.json, so they are fetched once and kept in the store.
|
||||
#
|
||||
# To update: change rev and hash, set cargoHash to lib.fakeHash, build and copy the
|
||||
# expected hash, then run ./update-grammars.sh.
|
||||
let
|
||||
lockedGrammars = lib.importJSON ./grammars.json;
|
||||
|
||||
unwrapped = helix-unwrapped.overrideAttrs (
|
||||
final: prev: {
|
||||
version = "25.07.1-unstable-${final.src.rev}";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "helix-editor";
|
||||
repo = "helix";
|
||||
rev = "f6f3eb1fe4a73933466f30175843059a4381a985";
|
||||
hash = "sha256-yfNBfV6HWAQU/xZXwrFoedsSYsDmCDIlTHRxAZI6teY=";
|
||||
};
|
||||
|
||||
cargoDeps = rustPlatform.fetchCargoVendor {
|
||||
inherit (final) src pname version;
|
||||
hash = "sha256-oo59HhwOS3EeV/YI+NWirEkdzD9pzMot2lgphZeOxfc=";
|
||||
};
|
||||
|
||||
# The mdbook 0.5 patch from nixpkgs targets the release
|
||||
patches = [ ];
|
||||
|
||||
# Report the commit in `hx --version`
|
||||
env = prev.env // {
|
||||
HELIX_NIX_BUILD_REV = final.src.rev;
|
||||
};
|
||||
|
||||
# The version check expects the release version string
|
||||
doInstallCheck = false;
|
||||
}
|
||||
);
|
||||
in
|
||||
(helix.override {
|
||||
helix-unwrapped = unwrapped;
|
||||
inherit lockedGrammars;
|
||||
grammarsOverlay = lib.composeManyExtensions [
|
||||
# Keep nixpkgs' fixes for its pinned grammars
|
||||
helix.defaultGrammarsOverlay
|
||||
|
||||
(final: prev: {
|
||||
# The tree-sitter.json fix is already included upstream
|
||||
tree-sitter-tlaplus = prev.tree-sitter-tlaplus.overrideAttrs { patches = [ ]; };
|
||||
})
|
||||
|
||||
# Grammars Helix uses that nixpkgs doesn't package yet
|
||||
(
|
||||
final: prev:
|
||||
lib.mapAttrs' (
|
||||
name: grammar:
|
||||
lib.nameValuePair "tree-sitter-${name}" (
|
||||
lib.makeOverridable tree-sitter.buildGrammar {
|
||||
language = name;
|
||||
version = lib.sources.shortRev grammar.nurl.args.rev;
|
||||
src = pkgs.${grammar.nurl.fetcher} grammar.nurl.args;
|
||||
location = grammar.subpath;
|
||||
}
|
||||
)
|
||||
) (lib.filterAttrs (name: _: !(prev ? "tree-sitter-${name}")) lockedGrammars)
|
||||
)
|
||||
];
|
||||
}).overrideAttrs
|
||||
{ passthru.unwrapped = unwrapped; }
|
||||
@@ -1,79 +0,0 @@
|
||||
"""
|
||||
Lock the tree-sitter grammars of a Helix languages.toml into grammars.json, in the
|
||||
format nixpkgs' helix package takes as `lockedGrammars`.
|
||||
|
||||
Based on nixpkgs' pkgs/by-name/he/helix/generate_grammars.py, but each fetch gets a
|
||||
timeout and falls back to fetching over git. Some forges (e.g. Codeberg) can hang
|
||||
while generating archives.
|
||||
|
||||
Usage: generate-grammars.py <languages.toml> <grammars.json>
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import tomllib
|
||||
|
||||
TIMEOUT = 120
|
||||
|
||||
|
||||
async def nurl(url, rev, *extra):
|
||||
proc = await asyncio.create_subprocess_exec(
|
||||
"nurl", *extra, url, rev, "--json",
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE,
|
||||
)
|
||||
try:
|
||||
stdout, stderr = await asyncio.wait_for(proc.communicate(), TIMEOUT)
|
||||
except asyncio.TimeoutError:
|
||||
proc.kill()
|
||||
await proc.wait()
|
||||
raise RuntimeError(f"timed out after {TIMEOUT}s")
|
||||
if proc.returncode != 0:
|
||||
raise RuntimeError(stderr.decode().strip())
|
||||
return json.loads(stdout)
|
||||
|
||||
|
||||
async def lock(grammar, semaphore):
|
||||
source = grammar["source"]
|
||||
async with semaphore:
|
||||
try:
|
||||
result = await nurl(source["git"], source["rev"])
|
||||
except RuntimeError as e:
|
||||
print(f" {grammar['name']}: {e}, retrying over git", file=sys.stderr)
|
||||
result = await nurl(source["git"], source["rev"], "-f", "fetchgit")
|
||||
print(f" locked {grammar['name']}", file=sys.stderr)
|
||||
return grammar["name"].replace("_", "-"), {
|
||||
"nurl": result,
|
||||
"subpath": source.get("subpath"),
|
||||
}
|
||||
|
||||
|
||||
async def main(languages_toml, output):
|
||||
with open(languages_toml, "rb") as f:
|
||||
grammars = [
|
||||
g
|
||||
for g in tomllib.load(f).get("grammar", [])
|
||||
if "git" in g.get("source", {}) and "rev" in g["source"]
|
||||
]
|
||||
print(f"Locking {len(grammars)} grammars", file=sys.stderr)
|
||||
|
||||
semaphore = asyncio.Semaphore(os.cpu_count() or 4)
|
||||
results = await asyncio.gather(
|
||||
*(lock(g, semaphore) for g in grammars), return_exceptions=True
|
||||
)
|
||||
|
||||
failed = [(g["name"], r) for g, r in zip(grammars, results) if isinstance(r, Exception)]
|
||||
if failed:
|
||||
for name, error in failed:
|
||||
print(f"failed: {name}: {error}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
with open(output, "w") as f:
|
||||
json.dump(dict(sorted(results)), f, indent=2)
|
||||
f.write("\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main(*sys.argv[1:3]))
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,11 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Regenerate grammars.json for the Helix revision pinned in default.nix
|
||||
set -euo pipefail
|
||||
|
||||
dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
flake="$(git -C "$dir" rev-parse --show-toplevel)"
|
||||
|
||||
src="$(nix build --no-link --print-out-paths "$flake#helix-git.unwrapped.src")"
|
||||
|
||||
nix shell --inputs-from "$flake" nixpkgs#nurl nixpkgs#nix-prefetch-git nixpkgs#python3 -c \
|
||||
python3 -I "$dir/generate-grammars.py" "$src/languages.toml" "$dir/grammars.json"
|
||||
@@ -1,65 +0,0 @@
|
||||
{
|
||||
disko.devices = {
|
||||
disk = {
|
||||
main = {
|
||||
type = "disk";
|
||||
device = "/dev/nvme0n1";
|
||||
imageSize = "32G"; # For test VMs
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
boot = {
|
||||
size = "512M";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
mountOptions = [ "umask=0077" ];
|
||||
};
|
||||
};
|
||||
zfs = {
|
||||
end = "-4G";
|
||||
content = {
|
||||
type = "zfs";
|
||||
pool = "tank";
|
||||
};
|
||||
};
|
||||
swap = {
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "swap";
|
||||
discardPolicy = "both";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
zpool = {
|
||||
tank = {
|
||||
type = "zpool";
|
||||
rootFsOptions = {
|
||||
compression = "zstd";
|
||||
};
|
||||
mountpoint = null;
|
||||
postCreateHook = "zfs snapshot -r tank@blank && zfs hold -r blank tank@blank";
|
||||
|
||||
datasets = {
|
||||
root = {
|
||||
type = "zfs_fs";
|
||||
mountpoint = "/";
|
||||
};
|
||||
nix = {
|
||||
type = "zfs_fs";
|
||||
mountpoint = "/nix";
|
||||
};
|
||||
persist = {
|
||||
type = "zfs_fs";
|
||||
mountpoint = "/persist";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
+2
-20
@@ -33,14 +33,14 @@ in
|
||||
# pkgs-stable.winbox
|
||||
winbox4
|
||||
# whatsapp-for-linux
|
||||
karere
|
||||
wasistlos
|
||||
discord
|
||||
steam
|
||||
spotify
|
||||
# feishin
|
||||
eduvpn-client
|
||||
ryubing
|
||||
# bottles
|
||||
bottles
|
||||
prismlauncher
|
||||
foliate
|
||||
wireshark
|
||||
@@ -54,20 +54,6 @@ in
|
||||
winboat
|
||||
hieroglyphic
|
||||
shortwave
|
||||
clairvoyant
|
||||
constrict
|
||||
curtail
|
||||
gnome-decoder
|
||||
dialect
|
||||
impression
|
||||
keypunch
|
||||
gnome-mahjongg
|
||||
textpieces
|
||||
video-trimmer
|
||||
wike
|
||||
davinci-resolve
|
||||
kdePackages.kdenlive
|
||||
kicad
|
||||
|
||||
podman
|
||||
podman-compose
|
||||
@@ -264,10 +250,6 @@ in
|
||||
enable = true;
|
||||
user = "Jan-Bulthuis";
|
||||
email = "git@bulthuis.dev";
|
||||
signingKey = "${config.home.homeDirectory}/.ssh/id_ed25519.pub";
|
||||
allowedSigners = [
|
||||
"git@bulthuis.dev ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKKxoQSxfYqf9ITN8Fhckk8WbY4dwtBAXOhC9jxihJvq"
|
||||
];
|
||||
# TODO: Move
|
||||
ignores = [
|
||||
".envrc"
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.modules.profiles.server;
|
||||
in
|
||||
{
|
||||
options.modules.profiles.server = {
|
||||
enable = mkEnableOption "Base server profile";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
# Enabled modules
|
||||
modules = {
|
||||
profiles.base.enable = true;
|
||||
disko.enable = true;
|
||||
impermanence = {
|
||||
enable = true;
|
||||
resetScript = ''
|
||||
# Revert to the blank state for the root directory
|
||||
zfs rollback -r tank/root@blank
|
||||
'';
|
||||
};
|
||||
domain = {
|
||||
enable = mkDefault true;
|
||||
join = {
|
||||
userFile = config.sops.secrets."vm-join/user".path;
|
||||
passwordFile = config.sops.secrets."vm-join/password".path;
|
||||
domainOUFile = config.sops.secrets."vm-join/ou".path;
|
||||
};
|
||||
};
|
||||
ssh.enable = true;
|
||||
};
|
||||
|
||||
# Initialize domain join secrets
|
||||
sops.secrets."vm-join/user" = { };
|
||||
sops.secrets."vm-join/password" = { };
|
||||
sops.secrets."vm-join/ou" = { };
|
||||
|
||||
# Local user
|
||||
sops.secrets."passwords/local-hashed".neededForUsers = true;
|
||||
users.mutableUsers = false;
|
||||
users.users.local = {
|
||||
isNormalUser = true;
|
||||
group = "local";
|
||||
hashedPasswordFile = config.sops.secrets."passwords/local-hashed".path;
|
||||
extraGroups = [ "wheel" ];
|
||||
openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKKxoQSxfYqf9ITN8Fhckk8WbY4dwtBAXOhC9jxihJvq Admin"
|
||||
];
|
||||
};
|
||||
users.groups.local = { };
|
||||
home-manager.users.local =
|
||||
{ ... }:
|
||||
{
|
||||
home.stateVersion = "24.11";
|
||||
modules.profiles.base.enable = true;
|
||||
};
|
||||
|
||||
# System packages
|
||||
environment.systemPackages = with pkgs; [
|
||||
# TODO: Make module for utilities/scripts
|
||||
(writeShellScriptBin "system-update" "nixos-rebuild switch --flake git+https://git.bulthuis.dev/Jan/nixos-config")
|
||||
];
|
||||
|
||||
# Machine platform
|
||||
nixpkgs.hostPlatform = mkDefault "x86_64-linux";
|
||||
|
||||
# Set hostid (required for ZFS)
|
||||
networking.hostId = "deadbeef";
|
||||
|
||||
# Hardware configuration
|
||||
hardware.enableRedistributableFirmware = true;
|
||||
};
|
||||
}
|
||||
+60
-2
@@ -1,4 +1,5 @@
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
@@ -16,17 +17,74 @@ in
|
||||
config = mkIf cfg.enable {
|
||||
# Enabled modules
|
||||
modules = {
|
||||
profiles.server.enable = true;
|
||||
disko.profile = mkDefault "vm";
|
||||
profiles.base.enable = true;
|
||||
disko = {
|
||||
enable = true;
|
||||
profile = mkDefault "vm";
|
||||
};
|
||||
impermanence = {
|
||||
enable = true;
|
||||
resetScript = ''
|
||||
# Revert to the blank state for the root directory
|
||||
zfs rollback -r tank/root@blank
|
||||
'';
|
||||
};
|
||||
domain = {
|
||||
enable = true;
|
||||
join = {
|
||||
userFile = config.sops.secrets."vm-join/user".path;
|
||||
passwordFile = config.sops.secrets."vm-join/password".path;
|
||||
domainOUFile = config.sops.secrets."vm-join/ou".path;
|
||||
};
|
||||
};
|
||||
ssh.enable = true;
|
||||
};
|
||||
|
||||
# Initialize domain join secrets
|
||||
sops.secrets."vm-join/user" = { };
|
||||
sops.secrets."vm-join/password" = { };
|
||||
sops.secrets."vm-join/ou" = { };
|
||||
|
||||
# Autologin to root for access from hypervisor
|
||||
services.getty.autologinUser = "root";
|
||||
|
||||
# Local user
|
||||
sops.secrets."passwords/local-hashed".neededForUsers = true;
|
||||
users.mutableUsers = false;
|
||||
users.users.local = {
|
||||
isNormalUser = true;
|
||||
group = "local";
|
||||
hashedPasswordFile = config.sops.secrets."passwords/local-hashed".path;
|
||||
extraGroups = [ "wheel" ];
|
||||
openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKKxoQSxfYqf9ITN8Fhckk8WbY4dwtBAXOhC9jxihJvq Admin"
|
||||
];
|
||||
};
|
||||
users.groups.local = { };
|
||||
home-manager.users.local =
|
||||
{ ... }:
|
||||
{
|
||||
home.stateVersion = "24.11";
|
||||
modules.profiles.base.enable = true;
|
||||
};
|
||||
|
||||
# System packages
|
||||
environment.systemPackages = with pkgs; [
|
||||
# TODO: Make module for utilities/scripts
|
||||
(writeShellScriptBin "system-update" "nixos-rebuild switch --flake git+https://git.bulthuis.dev/Jan/nixos-config")
|
||||
];
|
||||
|
||||
# Enable qemu guest agent
|
||||
services.qemuGuest.enable = true;
|
||||
|
||||
# Machine platform
|
||||
nixpkgs.hostPlatform = "x86_64-linux";
|
||||
|
||||
# Set hostid (required for ZFS)
|
||||
networking.hostId = "deadbeef";
|
||||
|
||||
# Hardware configuration
|
||||
hardware.enableRedistributableFirmware = true;
|
||||
boot.initrd.availableKernelModules = [
|
||||
"ata_piix"
|
||||
"uhci_hcd"
|
||||
|
||||
Reference in new issue
Block a user