-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: lucasew <[email protected]>
- Loading branch information
Showing
9 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import <test-nixpkgs> { root = ./.; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- test.nix: Top level with is discouraged as it may shadow variables and break static checks. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ config | ||
, lib | ||
}: | ||
|
||
let | ||
cfg = config.foo; | ||
in { | ||
options.foo = lib.mkOption { | ||
type = # random example from nixpkgs | ||
with lib.types; | ||
attrsOf ( | ||
either path (submodule { | ||
options = { | ||
service = lib.mkOption { | ||
type = nullOr str; | ||
default = null; | ||
description = "The service on which to perform \<action\> after fetching."; | ||
}; | ||
|
||
action = lib.mkOption { | ||
type = addCheck str ( | ||
x: | ||
cfg.svcManager == "command" | ||
|| lib.elem x [ | ||
"restart" | ||
"reload" | ||
"nop" | ||
] | ||
); | ||
default = "nop"; | ||
description = "The action to take after fetching."; | ||
}; | ||
}; | ||
}) | ||
); | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import <test-nixpkgs> { root = ./.; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Validated successfully |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ config | ||
, lib | ||
}: | ||
|
||
let | ||
cfg = config.foo; | ||
|
||
inherit (lib) | ||
mkOption | ||
elem | ||
; | ||
|
||
inherit (lib.types) | ||
attrsOf | ||
either | ||
path | ||
submodule | ||
nullOr | ||
str | ||
addCheck | ||
; | ||
in { | ||
options.foo = mkOption { | ||
type = # random example from nixpkgs | ||
attrsOf ( | ||
either path (submodule { | ||
options = { | ||
service = mkOption { | ||
type = nullOr str; | ||
default = null; | ||
description = "The service on which to perform \<action\> after fetching."; | ||
}; | ||
|
||
action = mkOption { | ||
type = addCheck str ( | ||
x: | ||
cfg.svcManager == "command" | ||
|| elem x [ | ||
"restart" | ||
"reload" | ||
"nop" | ||
] | ||
); | ||
default = "nop"; | ||
description = "The action to take after fetching."; | ||
}; | ||
}; | ||
}) | ||
); | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import <test-nixpkgs> { root = ./.; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Validated successfully |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ config | ||
, lib | ||
}: | ||
|
||
let | ||
cfg = config.foo; | ||
in { | ||
options.foo = lib.mkOption { | ||
type = # random example from nixpkgs | ||
lib.types.attrsOf ( | ||
lib.types.either lib.types.path (lib.types.submodule { | ||
options = { | ||
service = lib.mkOption { | ||
type = lib.types.nullOr lib.types.str; | ||
default = null; | ||
description = "The service on which to perform \<action\> after fetching."; | ||
}; | ||
|
||
action = lib.mkOption { | ||
type = lib.types.addCheck lib.types.str ( | ||
x: | ||
cfg.svcManager == "command" | ||
|| lib.elem x [ | ||
"restart" | ||
"reload" | ||
"nop" | ||
] | ||
); | ||
default = "nop"; | ||
description = "The action to take after fetching."; | ||
}; | ||
}; | ||
}) | ||
); | ||
}; | ||
} | ||
|