Unverified Commit a19bf3e0 authored by Jia Xiaodong's avatar Jia Xiaodong Committed by GitHub
Browse files

Merge branch 'NixOS:master' into jxd/add-config

parents 88d183af a1c35e4d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -102,3 +102,6 @@ fb0e5be84331188a69b3edd31679ca6576edb75a

# systemd: break too long lines of Nix code
67643f8ec84bef1482204709073e417c9f07eb87

# {pkgs/development/cuda-modules,pkgs/test/cuda,pkgs/top-level/cuda-packages.nix}: reformat all CUDA files with nixfmt-rfc-style 2023-03-01
802a1b4d3338f24cbc4efd704616654456d75a94
+0 −5
Original line number Diff line number Diff line
@@ -159,7 +159,6 @@ nixos/modules/installer/tools/nix-fallback-paths.nix @raitobezarius @ma27

# C compilers
/pkgs/development/compilers/gcc
/pkgs/development/compilers/llvm @RaitoBezarius
/pkgs/development/compilers/emscripten @raitobezarius
/doc/languages-frameworks/emscripten.section.md @raitobezarius

@@ -204,10 +203,6 @@ pkgs/development/python-modules/buildcatrust/ @ajs124 @lukegb @mweinelt
/nixos/modules/services/databases/postgresql.nix @thoughtpolice
/nixos/tests/postgresql.nix @thoughtpolice

# Linux kernel
/pkgs/os-specific/linux/kernel    @raitobezarius
/pkgs/top-level/linux-kernels.nix @raitobezarius

# Hardened profile & related modules
/nixos/modules/profiles/hardened.nix @joachifm
/nixos/modules/security/hidepid.nix @joachifm
+9 −0
Original line number Diff line number Diff line
@@ -95,6 +95,14 @@
        - pkgs/top-level/haskell-packages.nix
        - pkgs/top-level/release-haskell.nix

"6.topic: julia":
  - any:
    - changed-files:
      - any-glob-to-any-file:
        - doc/languages-frameworks/julia.section.md
        - pkgs/development/compilers/julia/**/*
        - pkgs/development/julia-modules/**/*

"6.topic: jupyter":
  - any:
    - changed-files:
@@ -122,6 +130,7 @@
  - any:
    - changed-files:
      - any-glob-to-any-file:
        - pkgs/development/tools/misc/luarocks/*
        - pkgs/development/interpreters/lua-5/**/*
        - pkgs/development/interpreters/luajit/**/*
        - pkgs/development/lua-modules/**/*
+50 −0
Original line number Diff line number Diff line
# This file was copied mostly from check-maintainers-sorted.yaml.
# NOTE: Formatting with the RFC-style nixfmt command is not yet stable. See
# https://github.com/NixOS/rfcs/pull/166.
# Because of this, this action is not yet enabled for all files -- only for
# those who have opted in.
name: Check that Nix files are formatted

on:
  pull_request_target:
permissions:
  contents: read

jobs:
  nixos:
    runs-on: ubuntu-latest
    if: github.repository_owner == 'NixOS'
    steps:
      - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
        with:
          # pull_request_target checks out the base branch by default
          ref: refs/pull/${{ github.event.pull_request.number }}/merge
      - uses: cachix/install-nix-action@8887e596b4ee1134dae06b98d573bd674693f47c # v26
        with:
          # explicitly enable sandbox
          extra_nix_config: sandbox = true
      - name: Install nixfmt
        run: nix-env -f default.nix -iAP nixfmt-rfc-style
      - name: Check that Nix files are formatted according to the RFC style
        # Each environment variable beginning with NIX_FMT_PATHS_ is a list of
        # paths to check with nixfmt.
        env:
          # Format paths related to the Nixpkgs CUDA ecosystem.
          NIX_FMT_PATHS_CUDA: |
            pkgs/development/cuda-modules
            pkgs/test/cuda
            pkgs/top-level/cuda-packages.nix
        # Iterate over all environment variables beginning with NIX_FMT_PATHS_.
        run: |
          for env_var in "${!NIX_FMT_PATHS_@}"; do
            readarray -t paths <<< "${!env_var}"
            if [[ "${paths[*]}" == "" ]]; then
              echo "Error: $env_var is empty."
              exit 1
            fi
            echo "Checking paths: ${paths[@]}"
            if ! nixfmt --check "${paths[@]}"; then
              echo "Error: nixfmt failed."
              exit 1
            fi
          done
+60 −48
Original line number Diff line number Diff line
@@ -557,7 +557,7 @@ Names of files and directories should be in lowercase, with dashes between words

  ```nix
  foo {
    arg = ...;
    arg = <...>;
  }
  ```

@@ -566,14 +566,14 @@ Names of files and directories should be in lowercase, with dashes between words
  ```nix
  foo
  {
    arg = ...;
    arg = <...>;
  }
  ```

  Also fine is

  ```nix
  foo { arg = ...; }
  foo { arg = <...>; }
  ```

  if it's a short call.
@@ -581,6 +581,7 @@ Names of files and directories should be in lowercase, with dashes between words
- In attribute sets or lists that span multiple lines, the attribute names or list elements should be aligned:

  ```nix
  {
    # A long list.
    list = [
      elem1
@@ -606,16 +607,19 @@ Names of files and directories should be in lowercase, with dashes between words
        attr2 = "ggg";
      }
    ];
  }
  ```

- Short lists or attribute sets can be written on one line:

  ```nix
  {
    # A short list.
    list = [ elem1 elem2 elem3 ];

    # A short set.
    attrs = { x = 1280; y = 1024; };
  }
  ```

- Breaking in the middle of a function argument can give hard-to-read code, like
@@ -649,7 +653,7 @@ Names of files and directories should be in lowercase, with dashes between words
  ```nix
  { arg1, arg2 }:
  assert system == "i686-linux";
  stdenv.mkDerivation { ...
  stdenv.mkDerivation { /* ... */ }
  ```

  not
@@ -657,41 +661,41 @@ Names of files and directories should be in lowercase, with dashes between words
  ```nix
  { arg1, arg2 }:
    assert system == "i686-linux";
      stdenv.mkDerivation { ...
      stdenv.mkDerivation { /* ... */ }
  ```

- Function formal arguments are written as:

  ```nix
  { arg1, arg2, arg3 }:
  { arg1, arg2, arg3 }: { /* ... */ }
  ```

  but if they don't fit on one line they're written as:

  ```nix
  { arg1, arg2, arg3
  , arg4, ...
  , # Some comment...
    argN
  }:
  , arg4
  # Some comment...
  ,  argN
  }: { }
  ```

- Functions should list their expected arguments as precisely as possible. That is, write

  ```nix
  { stdenv, fetchurl, perl }: ...
  { stdenv, fetchurl, perl }: <...>
  ```

  instead of

  ```nix
  args: with args; ...
  args: with args; <...>
  ```

  or

  ```nix
  { stdenv, fetchurl, perl, ... }: ...
  { stdenv, fetchurl, perl, ... }: <...>
  ```

  For functions that are truly generic in the number of arguments (such as wrappers around `mkDerivation`) that have some required arguments, you should write them using an `@`-pattern:
@@ -700,7 +704,7 @@ Names of files and directories should be in lowercase, with dashes between words
  { stdenv, doCoverageAnalysis ? false, ... } @ args:

  stdenv.mkDerivation (args // {
    ... if doCoverageAnalysis then "bla" else "" ...
    foo = if doCoverageAnalysis then "bla" else "";
  })
  ```

@@ -710,32 +714,40 @@ Names of files and directories should be in lowercase, with dashes between words
  args:

  args.stdenv.mkDerivation (args // {
    ... if args ? doCoverageAnalysis && args.doCoverageAnalysis then "bla" else "" ...
    foo = if args ? doCoverageAnalysis && args.doCoverageAnalysis then "bla" else "";
  })
  ```

- Unnecessary string conversions should be avoided. Do

  ```nix
  {
    rev = version;
  }
  ```

  instead of

  ```nix
  {
    rev = "${version}";
  }
  ```

- Building lists conditionally _should_ be done with `lib.optional(s)` instead of using `if cond then [ ... ] else null` or `if cond then [ ... ] else [ ]`.

  ```nix
  {
    buildInputs = lib.optional stdenv.isDarwin iconv;
  }
  ```

  instead of

  ```nix
  {
    buildInputs = if stdenv.isDarwin then [ iconv ] else null;
  }
  ```

  As an exception, an explicit conditional expression with null can be used when fixing a important bug without triggering a mass rebuild.
Loading