Add Gowin FPGA toolchain for desktop development.
Vendor Gowin EDU IDE, add openFPGALoader/Yosys/nextpnr/Apicula, and USB udev rules for Tang boards.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
```
|
||||
flake.nix # nixosConfigurations.desktop
|
||||
hosts/desktop/ # 主机入口 + hardware 占位
|
||||
hosts/desktop/ # 主机入口 + hardware
|
||||
modules/
|
||||
common.nix # 用户 / 网络 / PipeWire / Clash / nix
|
||||
desktop-plasma.nix # Plasma 6 + SDDM
|
||||
@@ -15,6 +15,7 @@ modules/
|
||||
gaming.nix # Steam
|
||||
printing.nix # CUPS + HP ULD + 中文打印
|
||||
apps.nix # QQ/微信包装、开发工具等
|
||||
fpga.nix # 高云 FPGA(Gowin EDU IDE + 开源工具链)
|
||||
pkgs/hp-uld-driver.nix
|
||||
```
|
||||
|
||||
@@ -57,6 +58,17 @@ sudo nixos-rebuild switch --flake .#desktop
|
||||
|
||||
若 NVIDIA 黑屏:在 `modules/nvidia.nix` 把 `open = true` 改成 `false` 后重建。
|
||||
|
||||
## 高云 FPGA
|
||||
|
||||
| 工具 | 用途 | 命令 |
|
||||
|------|------|------|
|
||||
| Gowin EDA 教育版 | 官方 IDE / 综合 | `gowin-ide` 或 `gowin-env` → `gw_ide` |
|
||||
| openFPGALoader | 烧录(推荐替代官方 Programmer) | `openFPGALoader -b tangnano9k -m foo.fs` |
|
||||
| yosys + nextpnr + apicula | 开源综合与布局布线 | `yosys` / `nextpnr-himbaechel` / `gowin_pack` |
|
||||
| iverilog / verilator / gtkwave | 仿真与波形 | `iverilog` / `verilator` / `gtkwave` |
|
||||
|
||||
插上开发板后若无权限,重新插拔或重新登录(用户已加入 `dialout` / `plugdev`)。
|
||||
|
||||
## 相对原 `/etc/nixos` 的改动
|
||||
|
||||
- 去掉本机(Ultra 9 / Arc / 磁盘 UUID / NPU)相关硬件
|
||||
|
||||
Generated
+27
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1789684949,
|
||||
"narHash": "sha256-ZKhUe/2IJUq1JhKxKMu8rbkgSGmPP2ZCqlIPn40aGCM=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e554fab72f81915600f3f449b786fd9af40439a5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
../../modules/gaming.nix
|
||||
../../modules/printing.nix
|
||||
../../modules/apps.nix
|
||||
../../modules/fpga.nix
|
||||
];
|
||||
|
||||
networking.hostName = "desktop";
|
||||
|
||||
+26
-25
@@ -1,43 +1,42 @@
|
||||
# 目标机(i7-12700F + RTX 4060)上必须重新生成本文件,当前为占位骨架。
|
||||
#
|
||||
# 安装时在目标机执行:
|
||||
# sudo nixos-generate-config --root /mnt # 若在 live 安装环境
|
||||
# # 或已装系统上:
|
||||
# sudo nixos-generate-config
|
||||
# 然后把生成的 hardware-configuration.nix 内容覆盖本文件(保留下面 nvidia 相关不要被冲掉的话,
|
||||
# 显卡驱动在 modules/nvidia.nix,本文件只放磁盘/CPU/固件)。
|
||||
#
|
||||
# 切勿带着本仓库里旧机器(Ultra 9 / 另一块盘 UUID)的分区信息开机。
|
||||
|
||||
# Generated for this machine by ‘nixos-generate-config’ (from the installer).
|
||||
# Disk layout: single btrfs disk with /, /nix, /home subvolumes + ESP + swap.
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
|
||||
imports = [
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
];
|
||||
|
||||
boot.initrd.availableKernelModules = [
|
||||
"vmd"
|
||||
"xhci_pci"
|
||||
"ahci"
|
||||
"nvme"
|
||||
"usbhid"
|
||||
"uas"
|
||||
"sd_mod"
|
||||
];
|
||||
boot.initrd.kernelModules = [ ];
|
||||
boot.kernelModules = [ "kvm-intel" ];
|
||||
boot.extraModulePackages = [ ];
|
||||
|
||||
# === 必须按目标机实际分区改 UUID / 挂载点 ===
|
||||
# fileSystems."/" = { device = "/dev/disk/by-uuid/REPLACE-ROOT"; fsType = "ext4"; };
|
||||
# fileSystems."/boot" = { device = "/dev/disk/by-uuid/REPLACE-ESP"; fsType = "vfat"; options = [ "fmask=0077" "dmask=0077" ]; };
|
||||
# swapDevices = [ { device = "/dev/disk/by-uuid/REPLACE-SWAP"; } ];
|
||||
|
||||
fileSystems."/" = lib.mkDefault {
|
||||
device = "/dev/disk/by-uuid/REPLACE-ME-ROOT-UUID";
|
||||
fsType = "ext4";
|
||||
fileSystems."/" = {
|
||||
device = "/dev/disk/by-uuid/6fe797fa-edcc-4e9f-b3e0-aac88c454563";
|
||||
fsType = "btrfs";
|
||||
};
|
||||
|
||||
fileSystems."/boot" = lib.mkDefault {
|
||||
device = "/dev/disk/by-uuid/REPLACE-ME-BOOT-UUID";
|
||||
fileSystems."/nix" = {
|
||||
device = "/dev/disk/by-uuid/6fe797fa-edcc-4e9f-b3e0-aac88c454563";
|
||||
fsType = "btrfs";
|
||||
options = [ "subvol=nix" ];
|
||||
};
|
||||
|
||||
fileSystems."/home" = {
|
||||
device = "/dev/disk/by-uuid/6fe797fa-edcc-4e9f-b3e0-aac88c454563";
|
||||
fsType = "btrfs";
|
||||
options = [ "subvol=home" ];
|
||||
};
|
||||
|
||||
fileSystems."/boot" = {
|
||||
device = "/dev/disk/by-uuid/5779-DFED";
|
||||
fsType = "vfat";
|
||||
options = [
|
||||
"fmask=0077"
|
||||
@@ -45,7 +44,9 @@
|
||||
];
|
||||
};
|
||||
|
||||
swapDevices = lib.mkDefault [ ];
|
||||
swapDevices = [
|
||||
{ device = "/dev/disk/by-uuid/55d9c36c-6692-4fb7-bc2e-20fe4978576e"; }
|
||||
];
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
# 目标机(i7-12700F + RTX 4060)上必须重新生成本文件,当前为占位骨架。
|
||||
#
|
||||
# 安装时在目标机执行:
|
||||
# sudo nixos-generate-config --root /mnt # 若在 live 安装环境
|
||||
# # 或已装系统上:
|
||||
# sudo nixos-generate-config
|
||||
# 然后把生成的 hardware-configuration.nix 内容覆盖本文件(保留下面 nvidia 相关不要被冲掉的话,
|
||||
# 显卡驱动在 modules/nvidia.nix,本文件只放磁盘/CPU/固件)。
|
||||
#
|
||||
# 切勿带着本仓库里旧机器(Ultra 9 / 另一块盘 UUID)的分区信息开机。
|
||||
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
|
||||
|
||||
boot.initrd.availableKernelModules = [
|
||||
"xhci_pci"
|
||||
"ahci"
|
||||
"nvme"
|
||||
"usbhid"
|
||||
"uas"
|
||||
"sd_mod"
|
||||
];
|
||||
boot.initrd.kernelModules = [ ];
|
||||
boot.kernelModules = [ "kvm-intel" ];
|
||||
boot.extraModulePackages = [ ];
|
||||
|
||||
# === 必须按目标机实际分区改 UUID / 挂载点 ===
|
||||
# fileSystems."/" = { device = "/dev/disk/by-uuid/REPLACE-ROOT"; fsType = "ext4"; };
|
||||
# fileSystems."/boot" = { device = "/dev/disk/by-uuid/REPLACE-ESP"; fsType = "vfat"; options = [ "fmask=0077" "dmask=0077" ]; };
|
||||
# swapDevices = [ { device = "/dev/disk/by-uuid/REPLACE-SWAP"; } ];
|
||||
|
||||
fileSystems."/" = lib.mkDefault {
|
||||
device = "/dev/disk/by-uuid/REPLACE-ME-ROOT-UUID";
|
||||
fsType = "ext4";
|
||||
};
|
||||
|
||||
fileSystems."/boot" = lib.mkDefault {
|
||||
device = "/dev/disk/by-uuid/REPLACE-ME-BOOT-UUID";
|
||||
fsType = "vfat";
|
||||
options = [
|
||||
"fmask=0077"
|
||||
"dmask=0077"
|
||||
];
|
||||
};
|
||||
|
||||
swapDevices = lib.mkDefault [ ];
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
hardware.enableRedistributableFirmware = true;
|
||||
}
|
||||
+4
-1
@@ -16,7 +16,7 @@ let
|
||||
version = "4.1.1";
|
||||
src = pkgs.fetchurl {
|
||||
url = "https://dldir1v6.qq.com/weixin/Universal/Linux/WeChatLinux_x86_64.AppImage";
|
||||
hash = "sha256-RX26ArkbAxzdRBLu4HT7v/udnQax5Q/Bgi00hw4RSZA=";
|
||||
hash = "sha256-T1StKQLs1vb9xWgLc1R/gNVCO/RwsBI3pXmi5bPK7us=";
|
||||
};
|
||||
meta = pkgs.wechat.meta;
|
||||
};
|
||||
@@ -140,5 +140,8 @@ in
|
||||
eza
|
||||
fzf
|
||||
btop
|
||||
|
||||
opencode
|
||||
cursor-cli
|
||||
];
|
||||
}
|
||||
|
||||
@@ -55,6 +55,11 @@
|
||||
"flakes"
|
||||
];
|
||||
auto-optimise-store = true;
|
||||
substituters = [
|
||||
"https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store"
|
||||
"https://mirrors.ustc.edu.cn/nix-channels/store"
|
||||
"https://cache.nixos.org"
|
||||
];
|
||||
};
|
||||
|
||||
nix.gc = {
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
# 高云(Gowin)FPGA 开发:开源工具链 + 教育版 IDE + 下载器权限
|
||||
# IDE 包装源自 ryan4yin/nur-packages(本地 vendoring,因上游已注释掉该包)
|
||||
{ pkgs, ... }:
|
||||
|
||||
let
|
||||
gowin-eda-edu-ide = pkgs.callPackage ../pkgs/gowin-eda-edu-ide { };
|
||||
in
|
||||
{
|
||||
# openFPGALoader / 串口下载器
|
||||
users.groups.plugdev = { };
|
||||
users.users.whc.extraGroups = [
|
||||
"dialout"
|
||||
"plugdev"
|
||||
];
|
||||
|
||||
# FTDI / Sipeed Tang 等常见下载器(含 TAG+=uaccess,登录用户可直接访问)
|
||||
services.udev.extraRules = ''
|
||||
# openFPGALoader — FTDI 常见 VID/PID(Tang Nano / Primer 等)
|
||||
ACTION!="add|change", GOTO="gowin_fpga_end"
|
||||
SUBSYSTEM!="usb|tty|hidraw", GOTO="gowin_fpga_end"
|
||||
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", MODE="0664", GROUP="plugdev", TAG+="uaccess"
|
||||
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6014", MODE="0664", GROUP="plugdev", TAG+="uaccess"
|
||||
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", MODE="0664", GROUP="plugdev", TAG+="uaccess"
|
||||
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE="0664", GROUP="plugdev", TAG+="uaccess"
|
||||
# Sipeed / CMSIS-DAP 类
|
||||
ATTRS{idVendor}=="1d50", MODE="0664", GROUP="plugdev", TAG+="uaccess"
|
||||
ATTRS{idVendor}=="0d28", ATTRS{idProduct}=="0204", MODE="0664", GROUP="plugdev", TAG+="uaccess"
|
||||
LABEL="gowin_fpga_end"
|
||||
'';
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
# 烧录(官方 Programmer 在 NixOS 上不稳定,优先用这个)
|
||||
openfpgaloader
|
||||
|
||||
# 开源综合 / 布局布线(Apicula → nextpnr himbaechel/gowin)
|
||||
yosys
|
||||
nextpnr
|
||||
python3Packages.apycula
|
||||
|
||||
# 仿真与波形
|
||||
iverilog
|
||||
verilator
|
||||
gtkwave
|
||||
|
||||
# 高云教育版 IDE:gowin-env / gowin-ide → 启动 gw_ide
|
||||
# 强制 X11,避免 Wayland 下 Qt 插件崩溃
|
||||
(writeShellScriptBin "gowin-ide" ''
|
||||
export QT_QPA_PLATFORM=xcb
|
||||
exec ${gowin-eda-edu-ide}/bin/gowin-env "$@"
|
||||
'')
|
||||
gowin-eda-edu-ide
|
||||
];
|
||||
}
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
powerManagement.enable = false;
|
||||
powerManagement.finegrained = false;
|
||||
# Ada (40 系) 推荐开源内核模块;若黑屏可改 open = false
|
||||
open = true;
|
||||
open = false;
|
||||
nvidiaSettings = true;
|
||||
package = config.boot.kernelPackages.nvidiaPackages.stable;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
{
|
||||
lib,
|
||||
buildFHSEnv,
|
||||
freetype,
|
||||
xkeyboard_config,
|
||||
callPackage,
|
||||
}:
|
||||
let
|
||||
gowin-ide = callPackage ./gowin-ide.nix { };
|
||||
in
|
||||
buildFHSEnv {
|
||||
name = "gowin-env";
|
||||
targetPkgs =
|
||||
pkgs:
|
||||
# ldd /nix/store/*gowin-version/bin/gw_ide
|
||||
with pkgs; [
|
||||
gowin-ide
|
||||
# runtime dependencies
|
||||
libGL
|
||||
fontconfig
|
||||
libxcrypt-legacy
|
||||
zlib
|
||||
libuuid
|
||||
libpulseaudio
|
||||
glib
|
||||
dbus
|
||||
libusb1
|
||||
|
||||
nss
|
||||
nspr
|
||||
expat
|
||||
krb5
|
||||
libxcomposite
|
||||
libxdamage
|
||||
libxfixes
|
||||
libxtst
|
||||
|
||||
udev
|
||||
alsa-lib
|
||||
vulkan-loader
|
||||
libx11
|
||||
libxcursor
|
||||
libxi
|
||||
libxrandr
|
||||
libxkbcommon
|
||||
wayland
|
||||
qt5.qtwayland
|
||||
qt5.qtbase
|
||||
];
|
||||
profile = ''
|
||||
export LD_PRELOAD="${lib.getLib freetype}/lib/libfreetype.so"
|
||||
export QT_XKB_CONFIG_ROOT="${xkeyboard_config}/etc/X11/xkb"
|
||||
export QT_QPA_PLATFORM=xcb
|
||||
export FHS=1
|
||||
|
||||
gw_ide
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
{
|
||||
fetchurl,
|
||||
lib,
|
||||
stdenv,
|
||||
qt5,
|
||||
}:
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "gowin-eda-edu-ide";
|
||||
version = "1.9.11.01";
|
||||
|
||||
src = fetchurl {
|
||||
# https://www.gowinsemi.com.cn/faq.aspx
|
||||
url = "https://cdn.gowinsemi.com.cn/Gowin_V${version}_Education_Linux.tar.gz";
|
||||
sha256 = "sha256-I26TSznMquS74NZzgJtRDMQ4V9hg7z4WCSJ0ybkvrQ4=";
|
||||
};
|
||||
sourceRoot = ".";
|
||||
|
||||
buildInputs = [qt5.qtbase];
|
||||
nativeBuildInputs = [qt5.wrapQtAppsHook];
|
||||
|
||||
installPhase = ''
|
||||
_package-ide() {
|
||||
# install IDE
|
||||
cd IDE
|
||||
find doc/ -type f -exec install -Dm644 {} $out/{} \;
|
||||
find lib/ -type f -exec install -Dm644 {} $out/{} \;
|
||||
find data/ -type f -exec install -Dm644 {} $out/{} \;
|
||||
find share/ -type f -exec install -Dm644 {} $out/{} \;
|
||||
find simlib/ -type f -exec install -Dm644 {} $out/{} \;
|
||||
find ipcore/ -type f -exec install -Dm644 {} $out/{} \;
|
||||
find plugins/ -type f -exec install -Dm644 {} $out/{} \;
|
||||
find bin/vhdl_packages -type f -exec install -Dm644 {} $out/{} \;
|
||||
find bin/ -type f -exec install -Dm755 {} $out/{} \;
|
||||
|
||||
chmod 644 $out/bin/prim{itive.xml,_syn.vhd,_syn.v}
|
||||
chmod 644 $out/bin/qt.conf
|
||||
chmod 644 $out/bin/programmer.json
|
||||
|
||||
# fix ide launch error
|
||||
# libfreetype.so.6 from Gowin EDA ide could cause error when launch the IDE:
|
||||
# /opt/gowin-eda-edu-ide/bin/gw_ide: symbol lookup error: /usr/lib/libfontconfig.so.1: undefined symbol: FT_Done_MM_Var
|
||||
#
|
||||
# https://bbs.archlinux.org/viewtopic.php?id=251445
|
||||
# https://mathematica.stackexchange.com/questions/189306/cant-launch-mathematica-11-on-fedora-29
|
||||
rm -f $out/lib/libfreetype.so.6
|
||||
}
|
||||
_package-ide
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Gowin EDA, an easy to use integrated design environment provides design engineers one-stop solution from design entry to verification. (education version)";
|
||||
homepage = "http://www.gowinsemi.com.cn/faq.aspx";
|
||||
maintainers = with maintainers; [];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user