mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 03:29:45 +01:00
ci: add format script and use in CI pipeline
The format script can be used to automatically format the Nix source files and also verify that the files are formatted using the `-c` command argument. At the moment some files are exempt from the formatting to avoid causing merge conflicts in active pull requests. Finally, update the contribution guidelines to note that `nixfmt` should be used.
This commit is contained in:
parent
45abf3d38a
commit
70af3b126a
3 changed files with 81 additions and 7 deletions
|
@ -8,5 +8,6 @@ before_script:
|
|||
- mkdir -m 0755 -p /nix/var/nix/{profiles,gcroots}/per-user/$USER
|
||||
|
||||
script:
|
||||
- ./format -c
|
||||
- nix-shell . -A install
|
||||
- nix-shell tests -A run.all
|
||||
|
|
|
@ -91,12 +91,15 @@ In addition to the above commit message guidelines, try to follow the
|
|||
|
||||
### Style guidelines ###
|
||||
|
||||
The code in Home Manager should follow the [Nixpkgs syntax
|
||||
guidelines][]. Note, we prefer `lowerCamelCase` for variable and
|
||||
attribute names with the accepted exception of variables directly
|
||||
referencing packages in Nixpkgs which use a hyphenated style. For
|
||||
example, the Home Manager option `services.gpg-agent.enableSshSupport`
|
||||
references the `gpg-agent` package in Nixpkgs.
|
||||
The code in Home Manager is formatted by the [nixfmt][] tool and the
|
||||
formatting is checked in the pull request tests. Run the `format` tool
|
||||
inside the project repository before submitting your pull request.
|
||||
|
||||
Note, we prefer `lowerCamelCase` for variable and attribute names with
|
||||
the accepted exception of variables directly referencing packages in
|
||||
Nixpkgs which use a hyphenated style. For example, the Home Manager
|
||||
option `services.gpg-agent.enableSshSupport` references the
|
||||
`gpg-agent` package in Nixpkgs.
|
||||
|
||||
### News ###
|
||||
|
||||
|
@ -158,4 +161,4 @@ If you do have a change worthy of a news entry then please add one in
|
|||
[create a pull request]: https://help.github.com/articles/creating-a-pull-request/
|
||||
[seven rules]: https://chris.beams.io/posts/git-commit/#seven-rules
|
||||
[`news.nix`]: https://github.com/rycee/home-manager/blob/master/modules/misc/news.nix
|
||||
[Nixpkgs syntax guidelines]: https://nixos.org/nixpkgs/manual/#sec-syntax
|
||||
[nixfmt]: https://github.com/serokell/nixfmt/
|
||||
|
|
70
format
Executable file
70
format
Executable file
|
@ -0,0 +1,70 @@
|
|||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i bash -p findutils nixfmt
|
||||
|
||||
CHECK_ARG=
|
||||
|
||||
case $1 in
|
||||
-h)
|
||||
echo "$0 [-c]"
|
||||
;;
|
||||
-c)
|
||||
CHECK_ARG=-c
|
||||
;;
|
||||
esac
|
||||
|
||||
# The first block of excludes are files where nixfmt does a poor job,
|
||||
# IMHO. The second block of excludes are files touched by open pull
|
||||
# requests and we want to avoid merge conflicts.
|
||||
find . -name '*.nix' \
|
||||
! -path ./modules/programs/irssi.nix \
|
||||
\
|
||||
! -path ./home-manager/default.nix \
|
||||
! -path ./home-manager/home-manager.nix \
|
||||
! -path ./modules/accounts/email.nix \
|
||||
! -path ./modules/default.nix \
|
||||
! -path ./modules/files.nix \
|
||||
! -path ./modules/home-environment.nix \
|
||||
! -path ./modules/lib/default.nix \
|
||||
! -path ./modules/lib/file-type.nix \
|
||||
! -path ./modules/lib/types.nix \
|
||||
! -path ./modules/manual.nix \
|
||||
! -path ./modules/misc/dconf.nix \
|
||||
! -path ./modules/misc/gtk.nix \
|
||||
! -path ./modules/misc/news.nix \
|
||||
! -path ./modules/misc/nixpkgs.nix \
|
||||
! -path ./modules/misc/xdg.nix \
|
||||
! -path ./modules/modules.nix \
|
||||
! -path ./modules/programs/afew.nix \
|
||||
! -path ./modules/programs/alot.nix \
|
||||
! -path ./modules/programs/bash.nix \
|
||||
! -path ./modules/programs/emacs.nix \
|
||||
! -path ./modules/programs/firefox.nix \
|
||||
! -path ./modules/programs/fish.nix \
|
||||
! -path ./modules/programs/gpg.nix \
|
||||
! -path ./modules/programs/lesspipe.nix \
|
||||
! -path ./modules/programs/neovim.nix \
|
||||
! -path ./modules/programs/ssh.nix \
|
||||
! -path ./modules/programs/tmux.nix \
|
||||
! -path ./modules/programs/vscode.nix \
|
||||
! -path ./modules/programs/zsh.nix \
|
||||
! -path ./modules/services/gpg-agent.nix \
|
||||
! -path ./modules/services/kbfs.nix \
|
||||
! -path ./modules/services/keybase.nix \
|
||||
! -path ./modules/services/mpd.nix \
|
||||
! -path ./modules/services/sxhkd.nix \
|
||||
! -path ./modules/services/window-managers/i3.nix \
|
||||
! -path ./modules/systemd.nix \
|
||||
! -path ./nix-darwin/default.nix \
|
||||
! -path ./tests/default.nix \
|
||||
! -path ./tests/modules/home-environment/default.nix \
|
||||
! -path ./tests/modules/home-environment/session-variables.nix \
|
||||
! -path ./tests/modules/programs/gpg/override-defaults.nix \
|
||||
! -path ./tests/modules/programs/tmux/default.nix \
|
||||
! -path ./tests/modules/programs/tmux/disable-confirmation-prompt.nix \
|
||||
! -path ./tests/modules/programs/tmux/secure-socket-enabled.nix \
|
||||
! -path ./tests/modules/programs/zsh/session-variables.nix \
|
||||
! -path ./tests/modules/services/sxhkd/service.nix \
|
||||
! -path ./tests/modules/systemd/default.nix \
|
||||
! -path ./tests/modules/systemd/services.nix \
|
||||
! -path ./tests/modules/systemd/session-variables.nix \
|
||||
-exec nixfmt $CHECK_ARG {} +
|
Loading…
Reference in a new issue