1
Fork 0
mirror of https://github.com/RGBCube/alejandra synced 2025-07-30 12:07:46 +00:00

feat: update rnix

- Update rnix to its latest version.
- Since the AST changes significantly for select (a.b.c)
  and bin-ops (a + b + c), temporarily don't format those.
- Since |> is a bin-op, then this adds support for those operators.
This commit is contained in:
Kevin Amado 2025-02-23 17:17:53 -07:00
parent de80b8ee31
commit 24204cb3e1
21 changed files with 130 additions and 300 deletions

65
Cargo.lock generated
View file

@ -50,15 +50,6 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "cbitset"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29b6ad25ae296159fb0da12b970b2fe179b234584d7cd294c891e2bbb284466b"
dependencies = [
"num-traits",
]
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.1.34" version = "1.1.34"
@ -115,9 +106,9 @@ dependencies = [
[[package]] [[package]]
name = "countme" name = "countme"
version = "2.0.4" version = "3.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "328b822bdcba4d4e402be8d9adb6eebf269f969f8eadef977a553ff3c4fbcb58" checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636"
[[package]] [[package]]
name = "diff" name = "diff"
@ -220,18 +211,18 @@ dependencies = [
"wasi", "wasi",
] ]
[[package]]
name = "hashbrown"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.12.3" version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "hashbrown"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.15.2" version = "0.15.2"
@ -301,15 +292,6 @@ version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "memoffset"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce"
dependencies = [
"autocfg",
]
[[package]] [[package]]
name = "mimalloc" name = "mimalloc"
version = "0.1.43" version = "0.1.43"
@ -319,15 +301,6 @@ dependencies = [
"libmimalloc-sys", "libmimalloc-sys",
] ]
[[package]]
name = "num-traits"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
dependencies = [
"autocfg",
]
[[package]] [[package]]
name = "num_cpus" name = "num_cpus"
version = "1.16.0" version = "1.16.0"
@ -434,24 +407,21 @@ dependencies = [
[[package]] [[package]]
name = "rnix" name = "rnix"
version = "0.10.2" version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8024a523e8836f1a5d051203dc00d833357fee94e351b51348dfaeca5364daa9" checksum = "6f15e00b0ab43abd70d50b6f8cd021290028f9b7fdd7cdfa6c35997173bc1ba9"
dependencies = [ dependencies = [
"cbitset",
"rowan", "rowan",
"smol_str",
] ]
[[package]] [[package]]
name = "rowan" name = "rowan"
version = "0.12.6" version = "0.15.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1b36e449f3702f3b0c821411db1cbdf30fb451726a9456dce5dabcd44420043" checksum = "0a542b0253fa46e632d27a1dc5cf7b930de4df8659dc6e720b647fc72147ae3d"
dependencies = [ dependencies = [
"countme", "countme",
"hashbrown 0.9.1", "hashbrown 0.14.5",
"memoffset",
"rustc-hash", "rustc-hash",
"text-size", "text-size",
] ]
@ -515,15 +485,6 @@ dependencies = [
"autocfg", "autocfg",
] ]
[[package]]
name = "smol_str"
version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fad6c857cbab2627dcf01ec85a623ca4e7dcb5691cbaa3d7fb7653671f0d09c9"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.10.0" version = "0.10.0"

View file

@ -1,7 +1,6 @@
[dependencies] [dependencies]
rnix = { version = "0.10.2", default-features = false, features = [] } rnix = { version = "*", default-features = false, features = [] }
# rowan follows rnix rowan = { version = "*", default-features = false, features = [] }
rowan = { version = "0.12.6", default-features = false, features = [] }
serde = { version = "*", default-features = false, features = ["derive"] } serde = { version = "*", default-features = false, features = ["derive"] }
[target.aarch64-unknown-linux-musl.dependencies.mimalloc] [target.aarch64-unknown-linux-musl.dependencies.mimalloc]

View file

@ -145,15 +145,23 @@ fn format(
// a b // a b
rnix::SyntaxKind::NODE_APPLY => crate::rules::apply::rule, rnix::SyntaxKind::NODE_APPLY => crate::rules::apply::rule,
// assert a; b // assert a; b
rnix::SyntaxKind::NODE_ASSERT => crate::rules::scoped::rule, rnix::SyntaxKind::NODE_ASSERT => crate::rules::scoped::rule, /* a.b.c */
rnix::SyntaxKind::NODE_ATTRPATH => crate::rules::default,
// a = b;
rnix::SyntaxKind::NODE_ATTRPATH_VALUE => {
crate::rules::key_value::rule
}
// { } // { }
rnix::SyntaxKind::NODE_ATTR_SET => crate::rules::attr_set::rule, rnix::SyntaxKind::NODE_ATTR_SET => crate::rules::attr_set::rule,
// a $op b // a $op b
rnix::SyntaxKind::NODE_BIN_OP => crate::rules::bin_op::rule, rnix::SyntaxKind::NODE_BIN_OP => crate::rules::default,
// ${a} (interpolation but for NODE_SELECT) // ${a} (interpolation but for NODE_SELECT)
rnix::SyntaxKind::NODE_DYNAMIC => crate::rules::dynamic::rule, rnix::SyntaxKind::NODE_DYNAMIC => crate::rules::dynamic::rule,
//
rnix::SyntaxKind::NODE_HAS_ATTR => crate::rules::default,
// $identifier // $identifier
rnix::SyntaxKind::NODE_IDENT => crate::rules::default, rnix::SyntaxKind::NODE_IDENT => crate::rules::default,
rnix::SyntaxKind::NODE_IDENT_PARAM => crate::rules::default,
// if a then b else c // if a then b else c
rnix::SyntaxKind::NODE_IF_ELSE => crate::rules::if_else::rule, rnix::SyntaxKind::NODE_IF_ELSE => crate::rules::if_else::rule,
// inherit NODE_INHERIT_FROM? b+ ; // inherit NODE_INHERIT_FROM? b+ ;
@ -162,47 +170,35 @@ fn format(
rnix::SyntaxKind::NODE_INHERIT_FROM => { rnix::SyntaxKind::NODE_INHERIT_FROM => {
crate::rules::paren::rule crate::rules::paren::rule
} }
rnix::SyntaxKind::NODE_KEY => crate::rules::default, // ${a}
// a = b; rnix::SyntaxKind::NODE_INTERPOL => crate::rules::paren::rule,
rnix::SyntaxKind::NODE_KEY_VALUE => {
crate::rules::key_value::rule
}
// a: b // a: b
rnix::SyntaxKind::NODE_LAMBDA => crate::rules::lambda::rule, rnix::SyntaxKind::NODE_LAMBDA => crate::rules::lambda::rule,
// let { }
rnix::SyntaxKind::NODE_LEGACY_LET => crate::rules::default,
// let NODE_KEY_VALUE* in b; // let NODE_KEY_VALUE* in b;
rnix::SyntaxKind::NODE_LET_IN => crate::rules::let_in::rule, rnix::SyntaxKind::NODE_LET_IN => crate::rules::let_in::rule,
// [ ... ] // [ ... ]
rnix::SyntaxKind::NODE_LIST => crate::rules::list::rule, rnix::SyntaxKind::NODE_LIST => crate::rules::list::rule,
// 1 | true | null // 1 | true | null
rnix::SyntaxKind::NODE_LITERAL => crate::rules::default, rnix::SyntaxKind::NODE_LITERAL => crate::rules::default,
// let { }
rnix::SyntaxKind::NODE_LEGACY_LET => crate::rules::default,
// a or b
rnix::SyntaxKind::NODE_OR_DEFAULT => crate::rules::bin_op::rule,
// ( a ) // ( a )
rnix::SyntaxKind::NODE_PAREN => crate::rules::paren::rule, rnix::SyntaxKind::NODE_PAREN => crate::rules::paren::rule,
// a | a ? b // a | a ? b
rnix::SyntaxKind::NODE_PAT_BIND => crate::rules::pat_bind::rule, rnix::SyntaxKind::NODE_PAT_BIND => crate::rules::pat_bind::rule,
// { NODE_PAT_ENTRY* }
rnix::SyntaxKind::NODE_PATTERN => crate::rules::pattern::rule,
// NODE_PAT_BIND | TOKEN_ELLIPSIS // NODE_PAT_BIND | TOKEN_ELLIPSIS
rnix::SyntaxKind::NODE_PAT_ENTRY => { rnix::SyntaxKind::NODE_PAT_ENTRY => {
crate::rules::pat_entry::rule crate::rules::pat_entry::rule
} }
// /path/to/${a} rnix::SyntaxKind::NODE_PATH => crate::rules::default,
rnix::SyntaxKind::NODE_PATH_WITH_INTERPOL => { // { NODE_PAT_ENTRY* }
crate::rules::default rnix::SyntaxKind::NODE_PATTERN => crate::rules::pattern::rule,
}
// implementation detail of rowan // implementation detail of rowan
rnix::SyntaxKind::NODE_ROOT => crate::rules::root::rule, rnix::SyntaxKind::NODE_ROOT => crate::rules::root::rule,
// a.b | a.NODE_DYNAMIC // a.b | a.NODE_DYNAMIC
rnix::SyntaxKind::NODE_SELECT => crate::rules::select::rule, rnix::SyntaxKind::NODE_SELECT => crate::rules::default,
// "..." || ''...'' // "..." || ''...''
rnix::SyntaxKind::NODE_STRING => crate::rules::string::rule, rnix::SyntaxKind::NODE_STRING => crate::rules::string::rule,
// ${a}
rnix::SyntaxKind::NODE_STRING_INTERPOL => {
crate::rules::paren::rule
}
// !a // !a
rnix::SyntaxKind::NODE_UNARY_OP => crate::rules::default, rnix::SyntaxKind::NODE_UNARY_OP => crate::rules::default,
// with a; b // with a; b

View file

@ -62,7 +62,7 @@ impl Children {
| rnix::SyntaxKind::NODE_LIST | rnix::SyntaxKind::NODE_LIST
| rnix::SyntaxKind::NODE_LITERAL | rnix::SyntaxKind::NODE_LITERAL
| rnix::SyntaxKind::NODE_PAREN | rnix::SyntaxKind::NODE_PAREN
| rnix::SyntaxKind::NODE_PATH_WITH_INTERPOL | rnix::SyntaxKind::NODE_INTERPOL
| rnix::SyntaxKind::NODE_STRING | rnix::SyntaxKind::NODE_STRING
) )
{ {

View file

@ -23,10 +23,10 @@ pub fn in_memory(
before: String, before: String,
config: Config, config: Config,
) -> (Status, String) { ) -> (Status, String) {
let tokens = rnix::tokenizer::Tokenizer::new(&before); let parsed = rnix::Root::parse(&before);
let ast = rnix::parser::parse(tokens);
let errors = parsed.errors();
let errors = ast.errors();
if !errors.is_empty() { if !errors.is_empty() {
return (Status::Error(errors[0].to_string()), before); return (Status::Error(errors[0].to_string()), before);
} }
@ -41,9 +41,10 @@ pub fn in_memory(
vertical: true, vertical: true,
}; };
let after = crate::builder::build(&mut build_ctx, ast.node().into()) let root = parsed.syntax();
.unwrap()
.to_string(); let after =
crate::builder::build(&mut build_ctx, root.into()).unwrap().to_string();
if before == after { if before == after {
(Status::Changed(false), after) (Status::Changed(false), after)

View file

@ -53,7 +53,7 @@ pub(crate) fn parse(
match child.kind() { match child.kind() {
rnix::SyntaxKind::NODE_PAT_ENTRY rnix::SyntaxKind::NODE_PAT_ENTRY
| rnix::SyntaxKind::TOKEN_CURLY_B_CLOSE | rnix::SyntaxKind::TOKEN_R_BRACE
| rnix::SyntaxKind::TOKEN_ELLIPSIS => { | rnix::SyntaxKind::TOKEN_ELLIPSIS => {
break; break;
} }
@ -76,7 +76,7 @@ pub(crate) fn parse(
// item // item
let child = children.peek_next().unwrap(); let child = children.peek_next().unwrap();
match child.kind() { match child.kind() {
rnix::SyntaxKind::TOKEN_CURLY_B_CLOSE => { rnix::SyntaxKind::TOKEN_R_BRACE => {
pattern.comments_before_curly_b_close = pattern.comments_before_curly_b_close =
argument.comments_before; argument.comments_before;
break; break;
@ -96,7 +96,7 @@ pub(crate) fn parse(
match child.kind() { match child.kind() {
rnix::SyntaxKind::NODE_PAT_ENTRY rnix::SyntaxKind::NODE_PAT_ENTRY
| rnix::SyntaxKind::TOKEN_ELLIPSIS | rnix::SyntaxKind::TOKEN_ELLIPSIS
| rnix::SyntaxKind::TOKEN_CURLY_B_CLOSE => { | rnix::SyntaxKind::TOKEN_R_BRACE => {
break; break;
} }
rnix::SyntaxKind::TOKEN_COMMA => { rnix::SyntaxKind::TOKEN_COMMA => {

View file

@ -8,16 +8,12 @@ pub(crate) fn rule(
let items_count = node let items_count = node
.children_with_tokens() .children_with_tokens()
.skip_while(|element| { .skip_while(|element| element.kind() != rnix::SyntaxKind::TOKEN_L_BRACE)
element.kind() != rnix::SyntaxKind::TOKEN_CURLY_B_OPEN .take_while(|element| element.kind() != rnix::SyntaxKind::TOKEN_R_BRACE)
})
.take_while(|element| {
element.kind() != rnix::SyntaxKind::TOKEN_CURLY_B_CLOSE
})
.filter(|element| { .filter(|element| {
matches!( matches!(
element.kind(), element.kind(),
rnix::SyntaxKind::NODE_KEY_VALUE rnix::SyntaxKind::NODE_ATTRPATH_VALUE
| rnix::SyntaxKind::NODE_INHERIT | rnix::SyntaxKind::NODE_INHERIT
| rnix::SyntaxKind::NODE_INHERIT_FROM | rnix::SyntaxKind::NODE_INHERIT_FROM
| rnix::SyntaxKind::TOKEN_COMMENT | rnix::SyntaxKind::TOKEN_COMMENT
@ -93,7 +89,7 @@ pub(crate) fn rule(
}); });
if let Some(child) = children.peek_next() { if let Some(child) = children.peek_next() {
if let rnix::SyntaxKind::TOKEN_CURLY_B_CLOSE = child.kind() { if let rnix::SyntaxKind::TOKEN_R_BRACE = child.kind() {
break; break;
} }

View file

@ -31,11 +31,7 @@ pub(crate) fn rule_with_configuration(
let kind = first.element.kind(); let kind = first.element.kind();
if (parent_kind == "bin_op_and_or_default" if (parent_kind == "bin_op_and_or_default"
&& matches!( && matches!(kind, rnix::SyntaxKind::NODE_BIN_OP))
kind,
rnix::SyntaxKind::NODE_BIN_OP
| rnix::SyntaxKind::NODE_OR_DEFAULT
))
|| (parent_kind == "select" || (parent_kind == "select"
&& matches!(kind, rnix::SyntaxKind::NODE_SELECT)) && matches!(kind, rnix::SyntaxKind::NODE_SELECT))
{ {

View file

@ -11,7 +11,7 @@ pub(crate) fn rule(
.filter(|element| { .filter(|element| {
matches!( matches!(
element.kind(), element.kind(),
rnix::SyntaxKind::NODE_KEY_VALUE rnix::SyntaxKind::NODE_ATTRPATH_VALUE
| rnix::SyntaxKind::NODE_INHERIT | rnix::SyntaxKind::NODE_INHERIT
| rnix::SyntaxKind::NODE_INHERIT_FROM | rnix::SyntaxKind::NODE_INHERIT_FROM
) )

View file

@ -62,7 +62,7 @@ pub(crate) fn rule(
if let Some(child) = children.peek_next() { if let Some(child) = children.peek_next() {
let child_kind = child.kind(); let child_kind = child.kind();
if let rnix::SyntaxKind::TOKEN_SQUARE_B_CLOSE = child_kind { if let rnix::SyntaxKind::TOKEN_R_BRACK = child_kind {
break; break;
} }

View file

@ -1,6 +1,6 @@
pub(crate) mod apply; pub(crate) mod apply;
pub(crate) mod attr_set; pub(crate) mod attr_set;
pub(crate) mod bin_op; // pub(crate) mod bin_op;
pub(crate) mod dynamic; pub(crate) mod dynamic;
pub(crate) mod if_else; pub(crate) mod if_else;
pub(crate) mod inherit; pub(crate) mod inherit;
@ -14,7 +14,7 @@ pub(crate) mod pat_entry;
pub(crate) mod pattern; pub(crate) mod pattern;
pub(crate) mod root; pub(crate) mod root;
pub(crate) mod scoped; pub(crate) mod scoped;
pub(crate) mod select; // pub(crate) mod select;
pub(crate) mod string; pub(crate) mod string;
pub(crate) fn default( pub(crate) fn default(

View file

@ -36,7 +36,6 @@ pub(crate) fn rule(
rnix::SyntaxKind::NODE_APPLY rnix::SyntaxKind::NODE_APPLY
| rnix::SyntaxKind::NODE_ASSERT | rnix::SyntaxKind::NODE_ASSERT
| rnix::SyntaxKind::NODE_BIN_OP | rnix::SyntaxKind::NODE_BIN_OP
| rnix::SyntaxKind::NODE_OR_DEFAULT
| rnix::SyntaxKind::NODE_LAMBDA | rnix::SyntaxKind::NODE_LAMBDA
| rnix::SyntaxKind::NODE_SELECT | rnix::SyntaxKind::NODE_SELECT
| rnix::SyntaxKind::NODE_WITH | rnix::SyntaxKind::NODE_WITH

View file

@ -59,7 +59,7 @@ pub(crate) fn rule(
// { // {
steps.push_back(crate::builder::Step::Token( steps.push_back(crate::builder::Step::Token(
rnix::SyntaxKind::TOKEN_CURLY_B_OPEN, rnix::SyntaxKind::TOKEN_L_BRACE,
"{".to_string(), "{".to_string(),
)); ));
if vertical { if vertical {
@ -138,7 +138,7 @@ pub(crate) fn rule(
} }
} }
steps.push_back(crate::builder::Step::Token( steps.push_back(crate::builder::Step::Token(
rnix::SyntaxKind::TOKEN_CURLY_B_OPEN, rnix::SyntaxKind::TOKEN_R_BRACE,
"}".to_string(), "}".to_string(),
)); ));

View file

@ -1,49 +1,10 @@
[ [
(1 + 1) (1 + 1)
(1 (1 +/**/1)
+ (1/**/+ 1)
/**/ (1/**/+/**/1)
1) (1/**/+/**/(1/**/+/**/(1/**/+/**/1)))
(1
/**/
+ 1)
(1
/**/
+
/**/
1)
(1
/**/
+
/**/
(1
/**/
+
/**/
(1
/**/
+
/**/
1)))
(1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1) (1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1)
(1 (1
+ 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1)
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1)
] ]

View file

@ -1,10 +1,8 @@
a a.${
.${
/* /*
b b
*/ */
c c.${
.${
/* /*
d d
*/ */

View file

@ -98,7 +98,7 @@
builtins.bitAnd builtins.bitAnd
or (import ./zip-int-bits.nix or (import ./zip-int-bits.nix
(a: b: (a: b:
if a == 1 && b == 1 if a==1 && b==1
then 1 then 1
else 0)); else 0));
@ -109,7 +109,7 @@
builtins.bitOr builtins.bitOr
or (import ./zip-int-bits.nix or (import ./zip-int-bits.nix
(a: b: (a: b:
if a == 1 || b == 1 if a==1 || b==1
then 1 then 1
else 0)); else 0));
@ -120,7 +120,7 @@
builtins.bitXor builtins.bitXor
or (import ./zip-int-bits.nix or (import ./zip-int-bits.nix
(a: b: (a: b:
if a != b if a!=b
then 1 then 1
else 0)); else 0));
@ -482,9 +482,8 @@
Check whether something is a function or something Check whether something is a function or something
annotated with function args. annotated with function args.
*/ */
isFunction = f: isFunction = f: builtins.isFunction f ||
builtins.isFunction f (f ? __functor && isFunction (f.__functor f));
|| (f ? __functor && isFunction (f.__functor f));
/* /*
Convert the given positive integer to a string of its hexadecimal Convert the given positive integer to a string of its hexadecimal
@ -508,8 +507,9 @@
"13" = "D"; "13" = "D";
"14" = "E"; "14" = "E";
"15" = "F"; "15" = "F";
} }.${
.${toString d}; toString d
};
in in
lib.concatMapStrings toHexDigit (toBaseDigits 16 i); lib.concatMapStrings toHexDigit (toBaseDigits 16 i);

View file

@ -81,11 +81,10 @@ in {
}; };
boot.kernelParams = mkOption { boot.kernelParams = mkOption {
type = types.listOf (types.strMatching ''([^"[:space:]]|"[^"]*")+'' type = types.listOf (types.strMatching ''([^"[:space:]]|"[^"]*")+'' // {
// { name = "kernelParam";
name = "kernelParam"; description = "string, with spaces inside double quotes";
description = "string, with spaces inside double quotes"; });
});
default = []; default = [];
description = "Parameters added to the kernel command line."; description = "Parameters added to the kernel command line.";
}; };
@ -245,8 +244,7 @@ in {
"hid_logitech_hidpp" "hid_logitech_hidpp"
"hid_logitech_dj" "hid_logitech_dj"
"hid_microsoft" "hid_microsoft"
] ] ++ optionals pkgs.stdenv.hostPlatform.isx86 [
++ optionals pkgs.stdenv.hostPlatform.isx86 [
# Misc. x86 keyboard stuff. # Misc. x86 keyboard stuff.
"pcips2" "pcips2"
"atkbd" "atkbd"
@ -270,8 +268,8 @@ in {
# Implement consoleLogLevel both in early boot and using sysctl # Implement consoleLogLevel both in early boot and using sysctl
# (so you don't need to reboot to have changes take effect). # (so you don't need to reboot to have changes take effect).
boot.kernelParams = boot.kernelParams =
["loglevel=${toString config.boot.consoleLogLevel}"] ["loglevel=${toString config.boot.consoleLogLevel}"] ++
++ optionals config.boot.vesa ["vga=0x317" "nomodeset"]; optionals config.boot.vesa ["vga=0x317" "nomodeset"];
boot.kernel.sysctl."kernel.printk" = mkDefault config.boot.consoleLogLevel; boot.kernel.sysctl."kernel.printk" = mkDefault config.boot.consoleLogLevel;
@ -339,8 +337,7 @@ in {
# !!! Should this really be needed? # !!! Should this really be needed?
(isYes "MODULES") (isYes "MODULES")
(isYes "BINFMT_ELF") (isYes "BINFMT_ELF")
] ] ++ (optional (randstructSeed != "") (isYes "GCC_PLUGIN_RANDSTRUCT"));
++ (optional (randstructSeed != "") (isYes "GCC_PLUGIN_RANDSTRUCT"));
# nixpkgs kernels are assumed to have all required features # nixpkgs kernels are assumed to have all required features
assertions = assertions =

View file

@ -81,11 +81,10 @@ in {
}; };
boot.kernelParams = mkOption { boot.kernelParams = mkOption {
type = types.listOf (types.strMatching ''([^"[:space:]]|"[^"]*")+'' type = types.listOf (types.strMatching ''([^"[:space:]]|"[^"]*")+'' // {
// { name = "kernelParam";
name = "kernelParam"; description = "string, with spaces inside double quotes";
description = "string, with spaces inside double quotes"; });
});
default = []; default = [];
description = "Parameters added to the kernel command line."; description = "Parameters added to the kernel command line.";
}; };
@ -245,8 +244,7 @@ in {
"hid_logitech_hidpp" "hid_logitech_hidpp"
"hid_logitech_dj" "hid_logitech_dj"
"hid_microsoft" "hid_microsoft"
] ] ++ optionals pkgs.stdenv.hostPlatform.isx86 [
++ optionals pkgs.stdenv.hostPlatform.isx86 [
# Misc. x86 keyboard stuff. # Misc. x86 keyboard stuff.
"pcips2" "pcips2"
"atkbd" "atkbd"
@ -270,8 +268,8 @@ in {
# Implement consoleLogLevel both in early boot and using sysctl # Implement consoleLogLevel both in early boot and using sysctl
# (so you don't need to reboot to have changes take effect). # (so you don't need to reboot to have changes take effect).
boot.kernelParams = boot.kernelParams =
["loglevel=${toString config.boot.consoleLogLevel}"] ["loglevel=${toString config.boot.consoleLogLevel}"] ++
++ optionals config.boot.vesa ["vga=0x317" "nomodeset"]; optionals config.boot.vesa ["vga=0x317" "nomodeset"];
boot.kernel.sysctl."kernel.printk" = mkDefault config.boot.consoleLogLevel; boot.kernel.sysctl."kernel.printk" = mkDefault config.boot.consoleLogLevel;
@ -339,8 +337,7 @@ in {
# !!! Should this really be needed? # !!! Should this really be needed?
(isYes "MODULES") (isYes "MODULES")
(isYes "BINFMT_ELF") (isYes "BINFMT_ELF")
] ] ++ (optional (randstructSeed != "") (isYes "GCC_PLUGIN_RANDSTRUCT"));
++ (optional (randstructSeed != "") (isYes "GCC_PLUGIN_RANDSTRUCT"));
# nixpkgs kernels are assumed to have all required features # nixpkgs kernels are assumed to have all required features
assertions = assertions =

View file

@ -60,7 +60,10 @@ in {
type = type =
types.unspecified types.unspecified
// {
//
{
merge = merge =
mergeEqualOption; mergeEqualOption;
}; };
@ -68,24 +71,30 @@ in {
apply = kernelPackages: apply = kernelPackages:
kernelPackages.extend kernelPackages.extend
(self: super: { (self: super: {
kernel = kernel =
super.kernel.override super.kernel.override
(originalArgs: { (originalArgs: {
inherit inherit
randstructSeed randstructSeed
; ;
kernelPatches = kernelPatches =
(originalArgs.kernelPatches (originalArgs.kernelPatches
or [])
++ kernelPatches;
features = or
lib.recursiveUpdate
super.kernel.features [])
features;
}); ++
});
kernelPatches;
features =
lib.recursiveUpdate
super.kernel.features
features;
});
});
# We don't want to evaluate all of linuxPackages for the manual # We don't want to evaluate all of linuxPackages for the manual
# - some of it might not even evaluate correctly. # - some of it might not even evaluate correctly.

View file

@ -1,48 +1,14 @@
[ [
(a.b or c) (a.b or c)
(a.b (a.b or/**/c)
or (a.b/**/or c)
/**/ (a.b/**/or/**/c)
c) (a.b/**/or/**/(a.b/**/or/**/(a.b/**/or/**/c)))
(a.b (a.b/**/or/**/(a.b/**/or/**/(a.b/**/or/**/c)))
/**/
or c)
(a.b
/**/
or
/**/
c)
(a.b
/**/
or
/**/
(a.b
/**/
or
/**/
(a.b
/**/
or
/**/
c)))
(a.b
/**/
or
/**/
(a.b
/**/
or
/**/
(a.b
/**/
or
/**/
c)))
(a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a) (a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a)
(a.a (a.a or a.a # test
or a.a # test or a.a # test
or a.a # test or # test
or # test a.a or
a.a a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a)
or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a or a.a)
] ]

View file

@ -1,55 +1,9 @@
[ [
(a.a) (a . a)
(a (a ./**/a)
. (a/**/. a)
/**/ (a/**/./**/a)
a)
(a
/**/
.a)
(a
/**/
.
/**/
a)
(a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a) (a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a)
(a (a.a
.a .a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a)
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a
.a)
] ]