-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit removes the restriction of running the project only via single-user nix installation. To ensure disruptor is run with appropriate settings, a comparison is made betweeen global nix configuration and those specified in scripts/nix.conf file - any differences is clearly communicated to user
- Loading branch information
1 parent
9408c51
commit bd3e52e
Showing
2 changed files
with
89 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
let | ||
lib = (import <nixpkgs> { }).lib; | ||
# attrset representing current host nix settings | ||
global-nix-config = builtins.mapAttrs (_: value: value.value) | ||
(builtins.fromJSON (builtins.readFile ../.cache/.global-nix-conf)); | ||
# list of config file lines | ||
config-lines = lib.lists.remove "" | ||
(lib.strings.splitString "\n" (builtins.readFile ./nix.conf)); | ||
# list of tuples representing config lines | ||
config-kv-pairs = (builtins.map (x: | ||
lib.strings.splitString "=" (builtins.replaceStrings [ " = " ] [ "=" ] x)) | ||
config-lines); | ||
# attrset with strigified nix config values (i.e. "a b" instead of [ "a", "b" ], "true" instead of true | ||
disruptor-config-strs = builtins.listToAttrs (builtins.map (x: { | ||
name = (builtins.elemAt x 0); | ||
value = (builtins.elemAt x 1); | ||
}) config-kv-pairs); | ||
|
||
# Convert disruptor config string values into correct types (except for numbers) | ||
from_str = x: | ||
(if x == "true" then | ||
true | ||
else if x == "false" then | ||
false | ||
else if (builtins.length (lib.strings.splitString " " x) == 1) then | ||
x | ||
else | ||
(lib.strings.splitString " " x)); | ||
|
||
# attrset representing disruptor required config | ||
disruptor-config = | ||
builtins.mapAttrs (_: v: (from_str v)) disruptor-config-strs; | ||
|
||
# attrset representing diff in configuration | ||
different_settings = lib.attrsets.filterAttrsRecursive (k: v: | ||
(let global-value = builtins.getAttr k global-nix-config; | ||
in if (builtins.isInt global-value) then | ||
(builtins.toString global-value) != v | ||
else | ||
global-value != v)) disruptor-config; | ||
in different_settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters