Add flake #1

Closed
Artturin wants to merge 1 commit from addflake into main
4 changed files with 213 additions and 0 deletions

25
default.nix Normal file
View file

@ -0,0 +1,25 @@
{
system ? builtins.currentSystem,
}:
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
root = lock.nodes.${lock.root};
inherit (lock.nodes.${root.inputs.flake-compat}.locked)
owner
repo
rev
narHash
;
flake-compat = fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
sha256 = narHash;
};
flake = import flake-compat {
inherit system;
src = ./.;
};
in
flake.defaultNix

78
flake.lock Normal file
View file

@ -0,0 +1,78 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1733328505,
"narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1737003892,
"narHash": "sha256-RCzJE9wKByLCXmRBp+z8LK9EgdW+K+W/DXnJS4S/NVo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ae06b9c2d83cb5c8b12d7d0e32692e93d1379713",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": "nixpkgs",
"utils": "utils"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"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"
}
}
},
"root": "root",
"version": 7
}

85
flake.nix Normal file
View file

@ -0,0 +1,85 @@
{
inputs = {
nixpkgs = {
url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
utils.url = "github:numtide/flake-utils";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs =
inputs:
inputs.utils.lib.eachDefaultSystem (
system:
let
pkgs = import inputs.nixpkgs {
localSystem = system;
overlays = [
(final: prev: {
bluespec-joh-template = prev.callPackage (
{
stdenv,
bluespec,
nextpnr,
openfpgaloader,
trellis,
which,
yosys,
}:
stdenv.mkDerivation {
pname = "bluespec-joh-template";
version = "0.1.0";
src = inputs.self;
# Versions can be checked with
# `nix eval --json ".#bluespec-joh-template.nativeBuildInputs" | nix-shell -p jq --run jq`
nativeBuildInputs = [
bluespec
nextpnr
openfpgaloader
trellis
which
yosys
];
makeFlags = [
"-C"
"ulx3s_fpga"
"mkTop.bit"
];
installPhase = ''
runHook preInstall
mkdir -p $out
cp ./ulx3s_fpga/mkTop.bit $out/
runHook postInstall
'';
}
) { };
})
];
};
in
{
packages = {
default = inputs.self.packages."${system}".bluespec-joh-template;
bluespec-joh-template = pkgs.bluespec-joh-template;
};
devShells.default = pkgs.callPackage (
{
mkShell,
bluespec-joh-template,
}:
mkShell {
inputsFrom = [ bluespec-joh-template ];
}
) { };
}
);
}

25
shell.nix Normal file
View file

@ -0,0 +1,25 @@
{
system ? builtins.currentSystem,
}:
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
root = lock.nodes.${lock.root};
inherit (lock.nodes.${root.inputs.flake-compat}.locked)
owner
repo
rev
narHash
;
flake-compat = fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
sha256 = narHash;
};
flake = import flake-compat {
inherit system;
src = ./.;
};
in
flake.shellNix