Merge pull request #58 from centromere/home-with-pure-eval

Add support for pure evaluation mode
This commit is contained in:
Robert Hensing 2022-07-13 12:02:14 +02:00 committed by GitHub
commit f840a659d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View file

@ -204,15 +204,17 @@ rec {
# Finding git config # Finding git config
# #
home = if lib.inPureEvalMode or false then _: /nonexistent else import ./home.nix;
maybeXdgGitConfigFile = maybeXdgGitConfigFile =
for for
(guardNonEmptyString (builtins.getEnv "XDG_CONFIG_HOME")) (guardNonEmptyString (builtins.getEnv "XDG_CONFIG_HOME"))
(xdgConfigHome: (xdgConfigHome:
guardFile (/. + xdgConfigHome + "/git/config") guardFile (/. + xdgConfigHome + "/git/config")
); );
maybeGlobalConfig = take 1 (guardFile ~/.gitconfig maybeGlobalConfig = take 1 (guardFile (home /.gitconfig)
++ maybeXdgGitConfigFile ++ maybeXdgGitConfigFile
++ guardFile ~/.config/git/config); ++ guardFile (home /.config/git/config));
globalConfigItems = for maybeGlobalConfig (globalConfigFile: globalConfigItems = for maybeGlobalConfig (globalConfigFile:
parse-ini.parseIniFile globalConfigFile parse-ini.parseIniFile globalConfigFile
@ -224,7 +226,7 @@ rec {
for for
(guard (toLower section == "core" && toLower key == "excludesfile")) (guard (toLower section == "core" && toLower key == "excludesfile"))
(_: (_:
resolveFile (~/.) value resolveFile (home /.) value
) )
) )
); );
@ -236,7 +238,7 @@ rec {
maybeGlobalIgnoresFile = take 1 maybeGlobalIgnoresFile = take 1
( globalConfiguredExcludesFile ( globalConfiguredExcludesFile
++ xdgExcludesFile ++ xdgExcludesFile
++ guardFile ~/.config/git/ignore); ++ guardFile (home /.config/git/ignore));
/* Given baseDir, which generalizes the idea of working directory, /* Given baseDir, which generalizes the idea of working directory,
resolve a file path relative to that directory. resolve a file path relative to that directory.
@ -247,7 +249,7 @@ rec {
*/ */
resolveFile = baseDir: path: take 1 resolveFile = baseDir: path: take 1
( if hasPrefix "/" path then guardFile (/. + path) else ( if hasPrefix "/" path then guardFile (/. + path) else
(if hasPrefix "~" path then guardFile (~/. + removePrefix "~" path) else []) (if hasPrefix "~" path then guardFile (home /. + removePrefix "~" path) else [])
++ guardFile (baseDir + "/" + path) ++ guardFile (baseDir + "/" + path)
) )
; ;

1
home.nix Normal file
View file

@ -0,0 +1 @@
path: ~/. + path