Skip to content
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

nginx: formating the config file #56280

Merged
merged 1 commit into from Feb 24, 2019
Merged

nginx: formating the config file #56280

merged 1 commit into from Feb 24, 2019

Conversation

Izorkin
Copy link
Contributor

@Izorkin Izorkin commented Feb 24, 2019

Motivation for this change

Formating the config file with awk to readable format.
Used this script - https://github.com/nixcloud/nixcloud-webservices/blob/master/modules/web/webserver/lib/nginx_check_config.nix

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@etu
Copy link
Contributor

etu commented Feb 24, 2019

@GrahamcOfBorg test nginx nginx-sso

@etu etu merged commit d7ba376 into NixOS:master Feb 24, 2019
@Izorkin
Copy link
Contributor Author

Izorkin commented Feb 24, 2019

Thanks!

@Izorkin Izorkin deleted the nginx-config branch February 24, 2019 07:58
@etu
Copy link
Contributor

etu commented Feb 24, 2019

@Izorkin Thanks, sometimes it's nice to have a more readable config. Most often it doesn't matter... But when you need it it's very handy.

Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review late, but please keep the comments in mind for the future.

@@ -44,7 +44,25 @@ let
}
''));

configFile = pkgs.writeText "nginx.conf" ''
awkFormat = pkgs.writeText "awkFormat-nginx.awk" ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually prefer builtins.toFile when the file is constant, because then there's one less derivation to build.

phases = [ "installPhase" ];
installPhase = ''
mkdir $out
awk -f ${awkFormat} ${pre-configFile} | sed '/^\s*$/d' > $out/nginx.conf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's pkgs.runCommand when you only need to run a command.

And you can output the file directly to $out, no need to make it a folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants