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-config-formatter: Init at 2016-06-16 #22179

Merged
merged 1 commit into from Jan 27, 2017
Merged

Conversation

Baughn
Copy link
Contributor

@Baughn Baughn commented Jan 26, 2017

Motivation for this change

I'd like to automatically format the nginx config file, when generated using structured config. At present the result is quite unreadable.

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • 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/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@Baughn, thanks for your PR! By analyzing the history of the files in this pull request, we identified @FRidh to be a potential reviewer.

Copy link
Contributor

@3noch 3noch left a comment

Choose a reason for hiding this comment

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

Do you plan on adding this to all-packages.nix as well so it's a top-level package?

${pkgs.python3}/bin/python $src/nginxfmt.py "\$@"
EOF
chmod a+x $out/bin/nginxfmt
'';
Copy link
Contributor

Choose a reason for hiding this comment

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

You can indent this block and it will be dedented automatically in nix.

Copy link
Contributor

Choose a reason for hiding this comment

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

or use makeWrapper.
BTW, won't this create runtime dependency on source derivation? Better would be to copy the sole .py file and wrap it.

Copy link
Contributor

Choose a reason for hiding this comment

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

If the source derivation only has one file then it's not really a problem to depend on it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, consider this as a nitpick.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makeWrapper, of course. D'oh.

But my original attempt was indented, and I ended up with EOF in the file. Not sure why; possibly tab/space confusion.

Don't have access to the machine this is on right now, though. I'll have another version up tomorrow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makeWrapper doesn't seem to let me specify a custom interpreter.

But that's fine. Specifying python3 in buildInputs makes the shebang patching work.

version = "2016-06-16";
name = "nginx-config-formatter-${version}";

src = pkgs.fetchgit {
Copy link
Contributor

Choose a reason for hiding this comment

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

fetchFromGitHub would probably be better here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -4697,6 +4697,25 @@ in {
};
};

nginx-config-formatter = stdenv.mkDerivation rec {
Copy link
Member

@rycee rycee Jan 26, 2017

Choose a reason for hiding this comment

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

If this is a tool and not a general Python library then its expression should be placed into its own directory. For example, pkgs/tools/system/nginx-config-formatter or pkgs/tools/misc/nginx-config-formatter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@3noch
Copy link
Contributor

3noch commented Jan 26, 2017

@Baughn BTW, I really like this idea. I agree the nginx config files are rough.

@Baughn
Copy link
Contributor Author

Baughn commented Jan 27, 2017

The commit log currently reflects the PR's history. Want me to squash it, or will you do that?

@FRidh
Copy link
Member

FRidh commented Jan 27, 2017

yes, squash it

@Baughn Baughn force-pushed the nginx branch 2 times, most recently from 59210da to d2cf7ff Compare January 27, 2017 14:53
@Baughn
Copy link
Contributor Author

Baughn commented Jan 27, 2017

Done.


stdenv.mkDerivation rec {
version = "2016-06-16";
name = "nginx-config-formatter-${version}";
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I didn't notice this earlier. If this is not an official release then the name should be nginx-config-formatter-unstable-${version} as per https://nixos.org/nixpkgs/manual/#sec-package-naming.

Copy link
Member

Choose a reason for hiding this comment

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

I'm of the opinion that if there isn't any stable release that we just drop the unstable. As soon as there will be a release we would likely use that instead of this version. In that case the name remains the same. If you would now append -unstable to the name part, the name changes and it would break nix-env -u.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, but later when, e.g., version 1.0 is released I believe nix-env -u will break anyway since 1.0 < 2016-06-16 and the user would have to manually force a package update.

Copy link
Member

Choose a reason for hiding this comment

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

@rycee you're right
https://nixos.org/nix/manual/#versions
I thought Nix didn't version comparisons but it does.

Copy link
Member

Choose a reason for hiding this comment

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

If I understand correctly it will check the version if you installed the package using the package name (nix-env -i xyz) and not the attribute name (nix-env -iA xyz).

I'm not sure, though. I don't use the nix-env -u mechanism at all so I've never been bitten by this.

In any case I think it is best to change the package name now when very few will be affected. It'll be more painful over time.

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

Successfully merging this pull request may close these issues.

None yet

7 participants