@@ -646,35 +646,28 @@ void ffDetectPackagesImpl(FFPackagesResult* result, FFPackagesOptions* options)
646646 #endif
647647
648648 ffStrbufSet (& baseDir , & instance .state .platform .homeDir );
649+
649650 if (!(options -> disabled & FF_PACKAGES_FLAG_NIX_BIT ))
650651 {
651- // check if ~/.nix-profile exists
652- FF_STRBUF_AUTO_DESTROY profilePath = ffStrbufCreateCopy (& baseDir );
653- ffStrbufAppendS (& profilePath , ".nix-profile" );
654- if (ffPathExists (profilePath .chars , FF_PATHTYPE_DIRECTORY ))
655- {
656- result -> nixUser += getNixPackages (& baseDir , ".nix-profile" );
657- }
652+ // Count packages from $HOME/.nix-profile
653+ result -> nixUser += getNixPackages (& baseDir , ".nix-profile" );
658654
659- // check if $XDG_STATE_HOME/nix/profile exists
660- FF_STRBUF_AUTO_DESTROY stateDir = ffStrbufCreate ();
661- const char * stateHome = getenv ("XDG_STATE_HOME" );
662- if (ffStrSet (stateHome ))
655+ // Check in $XDG_STATE_HOME/nix/profile
656+ FF_STRBUF_AUTO_DESTROY stateHome = ffStrbufCreate ();
657+ const char * stateHomeEnv = getenv ("XDG_STATE_HOME" );
658+ if (ffStrSet (stateHomeEnv ))
663659 {
664- ffStrbufSetS (& stateDir , stateHome );
665- ffStrbufEnsureEndsWithC (& stateDir , '/' );
660+ ffStrbufSetS (& stateHome , stateHomeEnv );
661+ ffStrbufEnsureEndsWithC (& stateHome , '/' );
666662 }
667663 else
668664 {
669- ffStrbufSet (& stateDir , & instance .state .platform .homeDir );
670- ffStrbufAppendS (& stateDir , ".local/state/" );
665+ ffStrbufSet (& stateHome , & instance .state .platform .homeDir );
666+ ffStrbufAppendS (& stateHome , ".local/state/" );
671667 }
668+ result -> nixUser += getNixPackages (& stateHome , "nix/profile" );
672669
673- ffStrbufSet (& profilePath , & stateDir );
674- ffStrbufAppendS (& profilePath , "nix/profile" );
675- result -> nixUser += getNixPackages (& stateDir , "nix/profile" );
676-
677- // check if /etc/profiles/per-user/$USER exists
670+ // Check in /etc/profiles/per-user/$USER
678671 FF_STRBUF_AUTO_DESTROY userPkgsDir = ffStrbufCreateStatic ("/etc/profiles/per-user/" );
679672 result -> nixUser += getNixPackages (& userPkgsDir , instance .state .platform .userName .chars );
680673 }
0 commit comments