Skip to content

Commit c7c41fb

Browse files
committed
[nix] clean up some nix dirty code
See chipsalliance/t1#817. Signed-off-by: Avimitin <[email protected]>
1 parent 61b6985 commit c7c41fb

File tree

3 files changed

+37
-33
lines changed

3 files changed

+37
-33
lines changed

templates/chisel/nix/overlay.nix

+9-19
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,22 @@
33

44
final: prev: {
55
espresso = final.callPackage ./pkgs/espresso.nix { };
6+
67
mill =
78
let jre = final.jdk21;
89
in (prev.mill.override { inherit jre; }).overrideAttrs
910
(_: { passthru = { inherit jre; }; });
11+
1012
fetchMillDeps = final.callPackage ./pkgs/mill-builder.nix { };
13+
1114
circt-full = final.callPackage ./pkgs/circt-full.nix { };
12-
add-determinism =
13-
final.callPackage ./pkgs/add-determinism { }; # faster strip-undetereminism
14-
15-
# Using VCS need to set VC_STATIC_HOME and SNPSLMD_LICENSE_FILE to impure env, and add sandbox dir to VC_STATIC_HOME
16-
# Remember to add "--impure" flag for nix to read this value from environment
17-
vcStaticHome = builtins.getEnv "VC_STATIC_HOME";
18-
snpslmdLicenseFile = builtins.getEnv "SNPSLMD_LICENSE_FILE";
19-
vcs-fhs-env = assert final.lib.assertMsg (final.vcStaticHome != "")
20-
"You forget to set VC_STATIC_HOME or the '--impure' flag";
21-
assert final.lib.assertMsg (final.snpslmdLicenseFile != "")
22-
"You forget to set SNPSLMD_LICENSE_FILE or the '--impure' flag";
23-
final.callPackage ./pkgs/vcs-fhs-env.nix { };
24-
jasperHome = builtins.getEnv "JASPER_HOME";
25-
cdsLicenseFile = builtins.getEnv "CDS_LIC_FILE";
26-
cds-fhs-env = assert final.lib.assertMsg (final.jasperHome != "")
27-
"You forget to set JASPER_HOME or the '--impure' flag";
28-
assert final.lib.assertMsg (final.cdsLicenseFile != "")
29-
"You forget to set CDS_LIC_FILE or the '--impure' flag";
30-
final.callPackage ./pkgs/cds-fhs-env.nix { };
3115

16+
# faster strip-undetereminism
17+
add-determinism = final.callPackage ./pkgs/add-determinism { };
18+
19+
vcs-fhs-env = final.callPackage ./pkgs/vcs-fhs-env.nix { };
20+
21+
cds-fhs-env = final.callPackage ./pkgs/cds-fhs-env.nix { };
3222

3323
projectDependencies = final.callPackage ./pkgs/project-dependencies.nix { };
3424

templates/chisel/nix/pkgs/cds-fhs-env.nix

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,34 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# SPDX-FileCopyrightText: 2024 Jiuyang Liu <[email protected]>
3-
{ jasperHome
4-
, cdsLicenseFile
3+
{ lib
54
, fetchFromGitHub
65
}:
76
let
87
nixpkgsSrcs = fetchFromGitHub {
98
owner = "NixOS";
109
repo = "nixpkgs";
11-
"rev" = "c374d94f1536013ca8e92341b540eba4c22f9c62";
12-
"hash" = "sha256-Z/ELQhrSd7bMzTO8r7NZgi9g5emh+aRKoCdaAv5fiO0=";
10+
rev = "c374d94f1536013ca8e92341b540eba4c22f9c62";
11+
hash = "sha256-Z/ELQhrSd7bMzTO8r7NZgi9g5emh+aRKoCdaAv5fiO0=";
1312
};
1413

1514
# The cds we have only support x86-64_linux
1615
lockedPkgs = import nixpkgsSrcs { system = "x86_64-linux"; };
16+
17+
jasperHome = builtins.getEnv "JASPER_HOME";
18+
cdsLicenseFile = builtins.getEnv "CDS_LIC_FILE";
1719
in
20+
assert lib.assertMsg (jasperHome != "")
21+
"You forget to set JASPER_HOME or the '--impure' flag";
22+
assert lib.assertMsg (cdsLicenseFile != "")
23+
"You forget to set CDS_LIC_FILE or the '--impure' flag";
24+
1825
lockedPkgs.buildFHSEnv {
1926
name = "cds-fhs-env";
2027

2128
profile = ''
22-
[ ! -e "${jasperHome}" ] && echo "env JASPER_HOME not set" && exit 1
23-
[ ! -d "${jasperHome}" ] && echo "JASPER_HOME not accessible" && exit 1
24-
[ -z "${cdsLicenseFile}" ] && echo "env CDS_LIC_FILE not set" && exit 1
29+
[ ! -e "${jasperHome}" ] && echo "env JASPER_HOME='${jasperHome}' points to unknown location" && exit 1
30+
[ ! -d "${jasperHome}" ] && echo "env JASPER_HOME='${jasperHome}' not accessible" && exit 1
31+
2532
export JASPER_HOME=${jasperHome}
2633
export CDS_LIC_FILE=${cdsLicenseFile}
2734
export PATH=$JASPER_HOME/bin:$PATH

templates/chisel/nix/pkgs/vcs-fhs-env.nix

+14-7
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,35 @@
77
#
88
# For convenience, we still use the nixpkgs defined in flake to "callPackage" this derivation.
99
# But the buildFHSEnv, targetPkgs is still from the locked nixpkgs.
10-
{ vcStaticHome
11-
, snpslmdLicenseFile
10+
{ lib
1211
, fetchFromGitHub
1312
}:
1413
let
1514
nixpkgsSrcs = fetchFromGitHub {
1615
owner = "NixOS";
1716
repo = "nixpkgs";
18-
"rev" = "c374d94f1536013ca8e92341b540eba4c22f9c62";
19-
"hash" = "sha256-Z/ELQhrSd7bMzTO8r7NZgi9g5emh+aRKoCdaAv5fiO0=";
17+
rev = "c374d94f1536013ca8e92341b540eba4c22f9c62";
18+
hash = "sha256-Z/ELQhrSd7bMzTO8r7NZgi9g5emh+aRKoCdaAv5fiO0=";
2019
};
2120

2221
# The vcs we have only support x86-64_linux
2322
lockedPkgs = import nixpkgsSrcs { system = "x86_64-linux"; };
23+
24+
vcStaticHome = builtins.getEnv "VC_STATIC_HOME";
25+
snpslmdLicenseFile = builtins.getEnv "SNPSLMD_LICENSE_FILE";
2426
in
27+
assert lib.assertMsg (vcStaticHome != "")
28+
"You forget to set VC_STATIC_HOME or the '--impure' flag";
29+
assert lib.assertMsg (snpslmdLicenseFile != "")
30+
"You forget to set SNPSLMD_LICENSE_FILE or the '--impure' flag";
31+
2532
lockedPkgs.buildFHSEnv {
2633
name = "vcs-fhs-env";
2734

2835
profile = ''
29-
[ ! -e "${vcStaticHome}" ] && echo "env VC_STATIC_HOME not set" && exit 1
30-
[ ! -d "${vcStaticHome}" ] && echo "VC_STATIC_HOME not accessible" && exit 1
31-
[ -z "${snpslmdLicenseFile}" ] && echo "env SNPS LICENSE not set" && exit 1
36+
[ ! -e "${vcStaticHome}" ] && echo "env VC_STATIC_HOME='${vcStaticHome}' points to unknown location" && exit 1
37+
[ ! -d "${vcStaticHome}" ] && echo "VC_STATIC_HOME='${vcStaticHome}' not accessible" && exit 1
38+
3239
export VC_STATIC_HOME=${vcStaticHome}
3340
3441
export TCL_TZ=UTC

0 commit comments

Comments
 (0)