-
Notifications
You must be signed in to change notification settings - Fork 58
overview: modularize NIX_CONFIG #1097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| name, | ||
| config, | ||
| lib, | ||
| ... | ||
| }: | ||
| let | ||
| inherit (lib) mkOption types; | ||
| in | ||
| { | ||
| options = { | ||
| name = mkOption { | ||
| type = types.str; | ||
| default = name; | ||
| }; | ||
| value = mkOption { | ||
| type = with types; either str (listOf str); | ||
| }; | ||
| }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| { | ||
| name, | ||
| config, | ||
| lib, | ||
| ... | ||
| }: | ||
| let | ||
| inherit (lib) mkOption types; | ||
| in | ||
| { | ||
| options = { | ||
| __toString = mkOption { | ||
| type = with types; functionTo str; | ||
| readOnly = true; | ||
| default = | ||
| self: | ||
| let | ||
| separator = "'$'\\n''"; | ||
| concatSettings = lib.concatStringsSep separator ( | ||
| lib.map (attrs: "${attrs.name} = ${toString attrs.value}") self.settings | ||
| ); | ||
| in | ||
| "NIX_CONFIG='${concatSettings}'"; | ||
| }; | ||
| settings = mkOption { | ||
| type = with types; listOf (submodule ./config-item.nix); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the submodule definition could be inlined here. I think file granularity still needs to be figured out but for now as a rule of thumb stuff that doesn't have a
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually nevermind, just saw what @fricklerhandwerk did in #1092 and it was his idea in the first place, so let's roll with this granularity.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It doesn't, but arguably we could have collapsed ./config-item into this module. |
||
| }; | ||
| }; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The NIX_CONFIG thing is a bit tricky. In the instructions what we really want to show is how to set the environment variable to the right value. This is challenging here because NIX_CONFIG is multiline. A convenient rendering will look differently for different shells. So what this change should really be about is
the nix configuration we don't need to re-invent -- it's already a NixOS module option, and we should even be able to re-use its rendering logic to produce a string that Nix will accept (not sure though, haven't looked).
then plug it all together such that it displays correctly in the project detail view.