use Nix devenv to manage project environment

This commit is contained in:
SikongJueluo 2024-09-09 21:35:00 +08:00
parent 042e5b1aac
commit 61b91e0688
No known key found for this signature in database
6 changed files with 211 additions and 3 deletions

3
.envrc Normal file
View File

@ -0,0 +1,3 @@
source_url "https://raw.githubusercontent.com/cachix/devenv/95f329d49a8a5289d31e0982652f7058a189bfca/direnvrc" "sha256-d+8cBpDfDBj41inrADaJt+bDWhOktwslgoP5YiGJ1v0="
use devenv

11
.gitignore vendored Normal file → Executable file
View File

@ -1,5 +1,6 @@
.idea/ .idea/
.vscode/ .vscode/
.devenv/
/CFA/sim/work/** /CFA/sim/work/**
*.wlf *.wlf
*.mpf *.mpf
@ -13,4 +14,12 @@
*.png *.png
!im.tif !im.tif
*.bmp *.bmp
*.out *.out# Devenv
.devenv*
devenv.local.nix
# direnv
.direnv
# pre-commit
.pre-commit-config.yaml

4
Color/SaturationCorrection.sv Normal file → Executable file
View File

@ -116,8 +116,8 @@ module SaturationCorrection #(
calState <= 3; calState <= 3;
end else if (calState == 3) begin end else if (calState == 3) begin
alpha <= (saturation_inc[31] == 0) ? ((saturation_inc + saturation >= 256) alpha <= (saturation_inc[31] == 0) ? ((saturation_inc + saturation >= 255)
? (65536 / saturation) - 256 : (65536 / (256 - saturation_inc)) - 256) ? (65536 / saturation) - 255 : (65536 / (256 - saturation_inc)) - 255)
: (saturation_inc); : (saturation_inc);
calState <= 4; calState <= 4;

122
devenv.lock Normal file
View File

@ -0,0 +1,122 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1725637114,
"owner": "cachix",
"repo": "devenv",
"rev": "c31e347a96dbb7718a0279afa993752a7dfc6a39",
"treeHash": "e0dfcbbfb0974603336900406b364bd4d1308fa4",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"treeHash": "2addb7b71a20a25ea74feeaf5c2f6a6b30898ecb",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"treeHash": "ca14199cabdfe1a06a7b1654c76ed49100a689f9",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1716977621,
"owner": "cachix",
"repo": "devenv-nixpkgs",
"rev": "4267e705586473d3e5c8d50299e71503f16a6fb6",
"treeHash": "6d9f1f7ca0faf1bc2eeb397c78a49623260d3412",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "rolling",
"repo": "devenv-nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1725693463,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "68e7dce0a6532e876980764167ad158174402c6f",
"treeHash": "ee872ee4d2426a6c3e1e4b3fa844550ce1b52b29",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1725513492,
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "7570de7b9b504cfe92025dd1be797bf546f66528",
"treeHash": "4b46d77870afecd8f642541cb4f4927326343b59",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks"
}
}
},
"root": "root",
"version": 7
}

59
devenv.nix Normal file
View File

@ -0,0 +1,59 @@
{ pkgs, lib, config, inputs, ... }:
{
# https://devenv.sh/basics/
env.GREET = "devenv";
# https://devenv.sh/packages/
packages = with pkgs; [
git
verilator
systemc
verible
svls
gtkwave
];
# https://devenv.sh/languages/
languages.rust.enable = true;
languages.c.enable = true;
languages.cplusplus.enable = true;
# https://devenv.sh/processes/
# processes.cargo-watch.exec = "cargo-watch";
# https://devenv.sh/services/
# services.postgres.enable = true;
# https://devenv.sh/scripts/
scripts.addEnv.exec = ''
export SYSTEMC_INCLUDE="${pkgs.systemc}/include"
echo $SYSTEMC_INCLUDE
export SYSTEMC_LIBDIR="${pkgs.systemc}/lib"
echo $SYSTEMC_LIBDIR
'';
enterShell = ''
addEnv
echo
git --version
echo
verilator --version
echo
gcc --version
'';
# https://devenv.sh/tests/
enterTest = ''
echo "Running tests"
git --version | grep --color=auto "${pkgs.git.version}"
'';
# https://devenv.sh/pre-commit-hooks/
# pre-commit.hooks.shellcheck.enable = true;
# See full reference at https://devenv.sh/reference/options/
}

15
devenv.yaml Normal file
View File

@ -0,0 +1,15 @@
# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json
inputs:
nixpkgs:
url: github:cachix/devenv-nixpkgs/rolling
# If you're using non-OSS software, you can set allowUnfree to true.
# allowUnfree: true
# If you're willing to use a package that's vulnerable
# permittedInsecurePackages:
# - "openssl-1.1.1w"
# If you have more than one devenv you can merge them
#imports:
# - ./backend