|
@@ -37,34 +37,55 @@ fn state-type {|@a|
|
|
|
|
|
|
var state-dir = (get-env XDG_STATE_HOME &default=~/.local/state)/direlv
|
|
var state-dir = (get-env XDG_STATE_HOME &default=~/.local/state)/direlv
|
|
var dir-stack = []
|
|
var dir-stack = []
|
|
-var ignore = [
|
|
|
|
|
|
+var quiet = [
|
|
AR
|
|
AR
|
|
|
|
+ AR_FOR_TARGET
|
|
AS
|
|
AS
|
|
|
|
+ AS_FOR_TARGET
|
|
CC
|
|
CC
|
|
- CONFIG_SHELL
|
|
|
|
|
|
+ CC_FOR_TARGET
|
|
CXX
|
|
CXX
|
|
- HOME
|
|
|
|
- HOST_PATH
|
|
|
|
|
|
+ CXX_FOR_TARGET
|
|
LD
|
|
LD
|
|
- LD_DYLD_PATH
|
|
|
|
- MACOSX_DEPLOYMENT_TARGET
|
|
|
|
|
|
+ LD_FOR_TARGET
|
|
NM
|
|
NM
|
|
- OBJCOPY
|
|
|
|
- OBJDUMP
|
|
|
|
- OLDPWD
|
|
|
|
|
|
+ NM_FOR_TARGET
|
|
RANLIB
|
|
RANLIB
|
|
- READELF
|
|
|
|
- SHELL
|
|
|
|
|
|
+ RANLIB_FOR_TARGET
|
|
SIZE
|
|
SIZE
|
|
- SOURCE_DATE_EPOCH
|
|
|
|
|
|
+ SIZE_FOR_TARGET
|
|
STRINGS
|
|
STRINGS
|
|
|
|
+ STRINGS_FOR_TARGET
|
|
STRIP
|
|
STRIP
|
|
|
|
+ STRIP_FOR_TARGET
|
|
|
|
+
|
|
|
|
+ READELF
|
|
|
|
+ OBJCOPY
|
|
|
|
+ OBJDUMP
|
|
|
|
+
|
|
|
|
+ MACOSX_DEPLOYMENT_TARGET
|
|
|
|
+
|
|
|
|
+ CONFIG_SHELL
|
|
|
|
+ HOST_PATH
|
|
|
|
+]
|
|
|
|
+var ignore = [
|
|
|
|
+ # keep user variables
|
|
|
|
+ HOME
|
|
|
|
+ OLDPWD
|
|
|
|
+ SHELL
|
|
TEMP
|
|
TEMP
|
|
TEMPDIR
|
|
TEMPDIR
|
|
TERM
|
|
TERM
|
|
TMP
|
|
TMP
|
|
TMPDIR
|
|
TMPDIR
|
|
TZ
|
|
TZ
|
|
|
|
+
|
|
|
|
+ # purity-related envs
|
|
|
|
+ NIX_ENFORCE_PURITY
|
|
|
|
+ SOURCE_DATE_EPOCH
|
|
|
|
+ ZERO_AR_DATE
|
|
|
|
+
|
|
|
|
+ # nix build variables
|
|
buildInputs
|
|
buildInputs
|
|
buildPhase
|
|
buildPhase
|
|
builder
|
|
builder
|
|
@@ -88,6 +109,7 @@ var ignore = [
|
|
outputs
|
|
outputs
|
|
patches
|
|
patches
|
|
phases
|
|
phases
|
|
|
|
+ preferLocalBuild
|
|
propagatedBuildInputs
|
|
propagatedBuildInputs
|
|
propagatedNativeBuildInputs
|
|
propagatedNativeBuildInputs
|
|
shell
|
|
shell
|
|
@@ -109,17 +131,33 @@ fn diff-env {|env|
|
|
} $env
|
|
} $env
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+fn print-change {|key new|
|
|
|
|
+ if (has-value $quiet $key) {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (str:has-prefix $key "NIX_") {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if $new {
|
|
|
|
+ put +$key
|
|
|
|
+ } else {
|
|
|
|
+ put -$key
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
fn apply-env {|env|
|
|
fn apply-env {|env|
|
|
each {|row|
|
|
each {|row|
|
|
var key value = (all $row)
|
|
var key value = (all $row)
|
|
if (eq $value $nil) {
|
|
if (eq $value $nil) {
|
|
- put -$key
|
|
|
|
|
|
+ print-change $key $false
|
|
unset-env $key
|
|
unset-env $key
|
|
} else {
|
|
} else {
|
|
- put +$key
|
|
|
|
|
|
+ print-change $key $true
|
|
set-env $key $value
|
|
set-env $key $value
|
|
}
|
|
}
|
|
- } $env
|
|
|
|
|
|
+ } $env | compact
|
|
}
|
|
}
|
|
|
|
|
|
fn env-from-nix-flake {|state-file|
|
|
fn env-from-nix-flake {|state-file|
|
|
@@ -127,15 +165,16 @@ fn env-from-nix-flake {|state-file|
|
|
keys $data[variables] | each {|key|
|
|
keys $data[variables] | each {|key|
|
|
var v = $data[variables][$key]
|
|
var v = $data[variables][$key]
|
|
if (eq $v[type] "exported") {
|
|
if (eq $v[type] "exported") {
|
|
- if (str:has-prefix $key "NIX_") {
|
|
|
|
- continue
|
|
|
|
- } elif (str:has-prefix $key "__") {
|
|
|
|
|
|
+ if (str:has-prefix $key "__") {
|
|
continue
|
|
continue
|
|
} elif (has-value $ignore $key) {
|
|
} elif (has-value $ignore $key) {
|
|
continue
|
|
continue
|
|
} elif (has-value $extend $key) {
|
|
} elif (has-value $extend $key) {
|
|
- var existing = (get-env $key)
|
|
|
|
var extended = $v[value]
|
|
var extended = $v[value]
|
|
|
|
+ if (eq $extended "") {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ var existing = (get-env $key)
|
|
if (not-eq $existing $nil) {
|
|
if (not-eq $existing $nil) {
|
|
set extended = $extended":"$existing
|
|
set extended = $extended":"$existing
|
|
}
|
|
}
|