flake.nix: add, builds legacy design

This commit is contained in:
2025-08-21 09:31:20 +08:00
parent 10b47f34af
commit 6fde32a18c
2 changed files with 127 additions and 0 deletions

44
flake.lock generated Normal file
View File

@@ -0,0 +1,44 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1755593991,
"narHash": "sha256-BA9MuPjBDx/WnpTJ0EGhStyfE7hug8g85Y3Ju9oTsM4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a58390ab6f1aa810eb8e0f0fc74230e7cc06de03",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-25.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"src-migen": "src-migen"
}
},
"src-migen": {
"flake": false,
"locked": {
"lastModified": 1749544952,
"narHash": "sha256-NshlPiORBHWljSUP5bB7YBxe7k8dW0t8UXOsIq2EK8I=",
"owner": "m-labs",
"repo": "migen",
"rev": "6e3a9e150fb006dabc4b55043d3af18dbfecd7e8",
"type": "github"
},
"original": {
"owner": "m-labs",
"repo": "migen",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

83
flake.nix Normal file
View File

@@ -0,0 +1,83 @@
{
description = "CPLD/FPGA gateware on Urukul";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
src-migen = {
url = "github:m-labs/migen";
flake = false;
};
};
outputs =
{
self,
nixpkgs,
src-migen,
}:
let
pkgs = import nixpkgs {
system = "x86_64-linux";
};
migen = pkgs.python3Packages.buildPythonPackage rec {
name = "migen";
src = src-migen;
pyproject = true;
build-system = [ pkgs.python3Packages.setuptools ];
propagatedBuildInputs = [ pkgs.python3Packages.colorama ];
};
ise =
let
isePath = "/opt/Xilinx/14.7/ISE_DS";
makeXilinxEnv =
name:
pkgs.buildFHSEnv {
inherit name;
targetPkgs =
pkgs:
(with pkgs; [
ncurses5
zlib
libuuid
xorg.libSM
xorg.libICE
xorg.libXrender
xorg.libX11
xorg.libXext
xorg.libXtst
xorg.libXi
]);
profile = ''
source ${isePath}/common/.settings64.sh ${isePath}/common
source ${isePath}/ISE/.settings64.sh ${isePath}/ISE
'';
runScript = name;
};
in
pkgs.lib.attrsets.genAttrs [ "xst" "ngdbuild" "cpldfit" "taengine" "hprep6" ] makeXilinxEnv;
in
rec {
packages.x86_64-linux = {
inherit migen;
urukul-cpld = pkgs.stdenv.mkDerivation {
name = "urukul-cpld";
src = self;
buildInputs = [ (pkgs.python3.withPackages (ps: [ migen ])) ] ++ (builtins.attrValues ise);
buildPhase = "python xc2c/urukul_impl.py";
installPhase = ''
mkdir -p $out $out/nix-support
cp build/urukul.jed $out
echo file binary-dist $out/urukul.jed >> $out/nix-support/hydra-build-products
'';
};
};
formatter.x86_64-linux = pkgs.nixfmt-tree;
hydraJobs = packages.x86_64-linux;
};
}