treewide: apply nixpkgs-fmt

This commit is contained in:
Tobias Happ 2022-09-03 17:10:19 +02:00
parent 241632822a
commit 7d1ed0fbaa
23 changed files with 64 additions and 61 deletions

4
ci.nix
View file

@ -5,7 +5,7 @@ with import <nixpkgs> { };
with lib; with lib;
let let
pkgs = (import ./pkgs {}) // { recurseForDerivations = true; }; pkgs = (import ./pkgs { }) // { recurseForDerivations = true; };
isCacheable = p: !(p.preferLocalBuild or false); isCacheable = p: !(p.preferLocalBuild or false);
shouldRecurseForDerivations = p: isAttrs p && p.recurseForDerivations or false; shouldRecurseForDerivations = p: isAttrs p && p.recurseForDerivations or false;
@ -16,7 +16,7 @@ let
else if isDerivation p then [ p ] else if isDerivation p then [ p ]
else [ ]; else [ ];
in in
concatMap f (attrValues s); concatMap f (attrValues s);
cachePkgs = filter isCacheable (flattenPkgs pkgs); cachePkgs = filter isCacheable (flattenPkgs pkgs);

View file

@ -18,15 +18,17 @@ let
pkgs.findutils pkgs.findutils
pkgs.gnugrep pkgs.gnugrep
pkgs.gnused pkgs.gnused
pkgs.ncurses # For `tput`. pkgs.ncurses # For `tput`.
config.nix.package config.nix.package
]; ];
mkActivationCmds = activation: concatStringsSep "\n" ( mkActivationCmds = activation: concatStringsSep "\n" (
mapAttrsToList (name: value: '' mapAttrsToList
noteEcho "Activating ${name}" (name: value: ''
${value} noteEcho "Activating ${name}"
'') activation ${value}
'')
activation
); );
activationScript = pkgs.writeScript "activation-script" '' activationScript = pkgs.writeScript "activation-script" ''
@ -79,7 +81,7 @@ in
build = { build = {
activation = mkOption { activation = mkOption {
default = {}; default = { };
type = types.attrs; type = types.attrs;
description = '' description = ''
Activation scripts for the nix-on-droid environment. Activation scripts for the nix-on-droid environment.
@ -87,7 +89,7 @@ in
}; };
activationBefore = mkOption { activationBefore = mkOption {
default = {}; default = { };
type = types.attrs; type = types.attrs;
description = '' description = ''
Activation scripts for the nix-on-droid environment that Activation scripts for the nix-on-droid environment that
@ -96,7 +98,7 @@ in
}; };
activationAfter = mkOption { activationAfter = mkOption {
default = {}; default = { };
type = types.attrs; type = types.attrs;
description = '' description = ''
Activation scripts for the nix-on-droid environment that Activation scripts for the nix-on-droid environment that

View file

@ -38,7 +38,7 @@ with lib;
extraProotOptions = mkOption { extraProotOptions = mkOption {
type = types.listOf types.string; type = types.listOf types.string;
default = []; default = [ ];
description = "Extra options passed to proot, e.g., extra bind mounts."; description = "Extra options passed to proot, e.g., extra bind mounts.";
}; };
}; };

View file

@ -14,9 +14,9 @@ let
defaultConfigFile = "${builtins.getEnv "HOME"}/.config/nixpkgs/nix-on-droid.nix"; defaultConfigFile = "${builtins.getEnv "HOME"}/.config/nixpkgs/nix-on-droid.nix";
configModule = configModule =
if config != null then config if config != null then config
else if builtins.pathExists defaultConfigFile then defaultConfigFile else if builtins.pathExists defaultConfigFile then defaultConfigFile
else if pkgs.config ? nix-on-droid then pkgs.config.nix-on-droid else if pkgs.config ? nix-on-droid then pkgs.config.nix-on-droid
else throw "No config file found! Create one in ~/.config/nixpkgs/nix-on-droid.nix"; else throw "No config file found! Create one in ~/.config/nixpkgs/nix-on-droid.nix";
rawModule = evalModules { rawModule = evalModules {
@ -38,7 +38,7 @@ let
failedAssertions = map (x: x.message) (filter (x: !x.assertion) rawModule.config.assertions); failedAssertions = map (x: x.message) (filter (x: !x.assertion) rawModule.config.assertions);
module = module =
if failedAssertions != [] if failedAssertions != [ ]
then throw "\nFailed assertions:\n${concatMapStringsSep "\n" (x: "- ${x}") failedAssertions}" then throw "\nFailed assertions:\n${concatMapStringsSep "\n" (x: "- ${x}") failedAssertions}"
else showWarnings rawModule.config.warnings rawModule; else showWarnings rawModule.config.warnings rawModule;
in in

View file

@ -12,9 +12,7 @@ in
###### interface ###### interface
options = { options = { };
};
###### implementation ###### implementation

View file

@ -19,7 +19,7 @@ let
targets = map (x: x.target) etc'; targets = map (x: x.target) etc';
}; };
fileType = types.submodule ( fileType = types.submodule (
{ name, config, ... }: { name, config, ... }:
{ {
options = { options = {
@ -58,7 +58,8 @@ let
target = mkDefault name; target = mkDefault name;
source = mkIf (config.text != null) ( source = mkIf (config.text != null) (
let name' = "etc-" + baseNameOf name; let name' = "etc-" + baseNameOf name;
in mkDefault (pkgs.writeText name' config.text)); in mkDefault (pkgs.writeText name' config.text)
);
}; };
} }
@ -74,7 +75,7 @@ in
environment = { environment = {
etc = mkOption { etc = mkOption {
type = types.loaOf fileType; type = types.loaOf fileType;
default = {}; default = { };
example = literalExample '' example = literalExample ''
{ {
example-configuration-file = { example-configuration-file = {

View file

@ -8,9 +8,7 @@ with lib;
###### interface ###### interface
options = { options = { };
};
###### implementation ###### implementation

View file

@ -39,7 +39,7 @@ in
nixPath = mkOption { nixPath = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = []; default = [ ];
description = '' description = ''
The default Nix expression search path, used by the Nix The default Nix expression search path, used by the Nix
evaluator to look up paths enclosed in angle brackets evaluator to look up paths enclosed in angle brackets
@ -108,7 +108,7 @@ in
substituters = mkOption { substituters = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = []; default = [ ];
description = '' description = ''
A list of URLs of substituters. The official NixOS and nix-on-droid A list of URLs of substituters. The official NixOS and nix-on-droid
substituters are added by default. substituters are added by default.
@ -117,7 +117,7 @@ in
trustedPublicKeys = mkOption { trustedPublicKeys = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = []; default = [ ];
description = '' description = ''
A list of public keys. When paths are copied from another Nix store (such as a A list of public keys. When paths are copied from another Nix store (such as a
binary cache), they must be signed with one of these keys. The official NixOS binary cache), they must be signed with one of these keys. The official NixOS
@ -165,7 +165,7 @@ in
}; };
} }
(mkIf (cfg.nixPath != []) { (mkIf (cfg.nixPath != [ ]) {
environment.sessionVariables.NIX_PATH = concatStringsSep ":" cfg.nixPath; environment.sessionVariables.NIX_PATH = concatStringsSep ":" cfg.nixPath;
}) })
]; ];

View file

@ -17,7 +17,7 @@ in
environment = { environment = {
packages = mkOption { packages = mkOption {
type = types.listOf types.package; type = types.listOf types.package;
default = []; default = [ ];
description = "List of packages to be installed as user packages."; description = "List of packages to be installed as user packages.";
}; };
@ -46,7 +46,7 @@ in
pkgs.bashInteractive pkgs.bashInteractive
pkgs.cacert pkgs.cacert
pkgs.coreutils pkgs.coreutils
pkgs.less # since nix tools really want a pager available, #27 pkgs.less # since nix tools really want a pager available, #27
config.nix.package config.nix.package
]; ];

View file

@ -50,7 +50,7 @@ in
options = { options = {
environment.sessionVariables = mkOption { environment.sessionVariables = mkOption {
default = {}; default = { };
type = types.attrs; type = types.attrs;
example = { EDITOR = "emacs"; GS_OPTIONS = "-sPAPERSIZE=a4"; }; example = { EDITOR = "emacs"; GS_OPTIONS = "-sPAPERSIZE=a4"; };
description = '' description = ''

View file

@ -8,9 +8,7 @@ with lib;
###### interface ###### interface
options = { options = { };
};
###### implementation ###### implementation

View file

@ -66,7 +66,7 @@ in
sharedModules = mkOption { sharedModules = mkOption {
type = with types; type = with types;
# TODO: use types.raw once this PR is merged: https://github.com/NixOS/nixpkgs/pull/132448 # TODO: use types.raw once this PR is merged: https://github.com/NixOS/nixpkgs/pull/132448
listOf (mkOptionType { listOf (mkOptionType {
name = "submodule"; name = "submodule";
inherit (submodule { }) check; inherit (submodule { }) check;

View file

@ -28,23 +28,25 @@ let
optionalAttrs (lhs ? packageOverrides) { optionalAttrs (lhs ? packageOverrides) {
packageOverrides = pkgs: packageOverrides = pkgs:
optCall lhs.packageOverrides pkgs // optCall lhs.packageOverrides pkgs //
optCall (attrByPath ["packageOverrides"] ({}) rhs) pkgs; optCall (attrByPath [ "packageOverrides" ] ({ }) rhs) pkgs;
} // } //
optionalAttrs (lhs ? perlPackageOverrides) { optionalAttrs (lhs ? perlPackageOverrides) {
perlPackageOverrides = pkgs: perlPackageOverrides = pkgs:
optCall lhs.perlPackageOverrides pkgs // optCall lhs.perlPackageOverrides pkgs //
optCall (attrByPath ["perlPackageOverrides"] ({}) rhs) pkgs; optCall (attrByPath [ "perlPackageOverrides" ] ({ }) rhs) pkgs;
}; };
configType = mkOptionType { configType = mkOptionType {
name = "nixpkgs-config"; name = "nixpkgs-config";
description = "nixpkgs config"; description = "nixpkgs config";
check = x: check = x:
let traceXIfNot = c: let
if c x then true traceXIfNot = c:
else lib.traceSeqN 1 x false; if c x then true
in traceXIfNot isConfig; else lib.traceSeqN 1 x false;
merge = args: fold (def: mergeConfig def.value) {}; in
traceXIfNot isConfig;
merge = args: fold (def: mergeConfig def.value) { };
}; };
overlayType = mkOptionType { overlayType = mkOptionType {
@ -161,7 +163,7 @@ in
assertions = [ assertions = [
{ {
assertion = isFlake -> config.nixpkgs.config == null && (config.nixpkgs.overlays == null || config.nixpkgs.overlays == []); assertion = isFlake -> config.nixpkgs.config == null && (config.nixpkgs.overlays == null || config.nixpkgs.overlays == [ ]);
message = "In a flake setup, the options nixpkgs.* should not be used. Instead, rely on the provided flake " message = "In a flake setup, the options nixpkgs.* should not be used. Instead, rely on the provided flake "
+ "outputs and pass in the necessary nixpkgs object."; + "outputs and pass in the necessary nixpkgs object.";
} }

View file

@ -13,7 +13,7 @@ let
cfg = config.time; cfg = config.time;
tzdir = "${pkgs.tzdata}/share/zoneinfo"; tzdir = "${pkgs.tzdata}/share/zoneinfo";
nospace = str: filter (c: c == " ") (stringToCharacters str) == []; nospace = str: filter (c: c == " ") (stringToCharacters str) == [ ];
timezoneType = types.nullOr (types.addCheck types.str nospace) timezoneType = types.nullOr (types.addCheck types.str nospace)
// { description = "null or string without spaces"; }; // { description = "null or string without spaces"; };
in in

View file

@ -7,7 +7,7 @@ with lib;
let let
cfg = config.user; cfg = config.user;
idsDerivation = pkgs.runCommandLocal "ids.nix" {} '' idsDerivation = pkgs.runCommandLocal "ids.nix" { } ''
cat > $out <<EOF cat > $out <<EOF
{ {
gid = $(${pkgs.coreutils}/bin/id -g); gid = $(${pkgs.coreutils}/bin/id -g);

View file

@ -4,10 +4,10 @@
runCommand runCommand
"nix-on-droid" "nix-on-droid"
{ {
preferLocalBuild = true; preferLocalBuild = true;
allowSubstitutes = false; allowSubstitutes = false;
} }
'' ''
install -D -m755 ${./nix-on-droid.sh} $out/bin/nix-on-droid install -D -m755 ${./nix-on-droid.sh} $out/bin/nix-on-droid

View file

@ -9,7 +9,7 @@ in
{ {
typespeed = nixpkgs.typespeed.overrideAttrs (old: { typespeed = nixpkgs.typespeed.overrideAttrs (old: {
patches = nixpkgs.typespeed.patches ++ [ patches = nixpkgs.typespeed.patches ++ [
./typespeed-no-drop-priv.patch ./typespeed-no-drop-priv.patch
]; ];
}); });
} }

View file

@ -7,7 +7,7 @@ let
stdenv = pkgsCross.stdenvAdapters.makeStaticBinaries pkgsCross.stdenv; stdenv = pkgsCross.stdenvAdapters.makeStaticBinaries pkgsCross.stdenv;
in in
pkgsCross.callPackage ../proot-termux { pkgsCross.callPackage ../proot-termux {
talloc = tallocStatic; talloc = tallocStatic;
inherit stdenv; inherit stdenv;
} }

View file

@ -21,7 +21,7 @@ pkgsCross.stdenv.mkDerivation rec {
}; };
nativeBuildInputs = [ pkg-config python3 wafHook ]; nativeBuildInputs = [ pkg-config python3 wafHook ];
buildInputs = []; buildInputs = [ ];
wafPath = "./buildtools/bin/waf"; wafPath = "./buildtools/bin/waf";
wafConfigureFlags = [ wafConfigureFlags = [

View file

@ -27,7 +27,7 @@ stdenv.mkDerivation {
sha256 = "179jjf9hy1860d7bsravykg15jqxdfm51fy14aihkjbc1q6knyyx"; sha256 = "179jjf9hy1860d7bsravykg15jqxdfm51fy14aihkjbc1q6knyyx";
}; };
PROOT_NO_SECCOMP = 1; # see https://github.com/proot-me/PRoot/issues/106 PROOT_NO_SECCOMP = 1; # see https://github.com/proot-me/PRoot/issues/106
buildPhase = '' buildPhase = ''
mkdir --parents ${buildRootDirectory}/nix mkdir --parents ${buildRootDirectory}/nix

View file

@ -1,7 +1,11 @@
# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE. # Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
{ stdenv, fetchFromGitHub, talloc, { stdenv
static ? true, outputBinaryName ? "proot-static" }: , fetchFromGitHub
, talloc
, static ? true
, outputBinaryName ? "proot-static"
}:
stdenv.mkDerivation { stdenv.mkDerivation {
pname = "proot-termux"; pname = "proot-termux";
@ -30,8 +34,8 @@ stdenv.mkDerivation {
patches = [ ./detranslate-empty.patch ]; patches = [ ./detranslate-empty.patch ];
makeFlags = [ "-Csrc" "V=1" ]; makeFlags = [ "-Csrc" "V=1" ];
CFLAGS = [ "-O3" "-I../fake-ashmem" ] ++ CFLAGS = [ "-O3" "-I../fake-ashmem" ] ++
(if static then [ "-static" ] else []); (if static then [ "-static" ] else [ ]);
LDFLAGS = if static then [ "-static" ] else []; LDFLAGS = if static then [ "-static" ] else [ ];
preInstall = "${stdenv.cc.targetPrefix}strip src/proot"; preInstall = "${stdenv.cc.targetPrefix}strip src/proot";
installPhase = "install -D -m 0755 src/proot $out/bin/${outputBinaryName}"; installPhase = "install -D -m 0755 src/proot $out/bin/${outputBinaryName}";
} }

View file

@ -14,5 +14,5 @@
nixpkgs.overlays = config.nixpkgs.overlays; nixpkgs.overlays = config.nixpkgs.overlays;
home.packages = with pkgs; [ dash ]; home.packages = with pkgs; [ dash ];
}; };
nixpkgs.overlays = []; nixpkgs.overlays = [ ];
} }

View file

@ -1,6 +1,6 @@
# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE. # Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
{ pkgs ? (import ../pkgs/lib/load-nixpkgs.nix {}) }: { pkgs ? (import ../pkgs/lib/load-nixpkgs.nix { }) }:
pkgs.callPackage ../pkgs/proot-termux { pkgs.callPackage ../pkgs/proot-termux {
stdenv = pkgs.stdenv; stdenv = pkgs.stdenv;