Skip to content

Commit a562943

Browse files
authored
Merge pull request #16 from Platonic-Systems/exec
Use singular option for command and package
2 parents 4b43702 + e625943 commit a562943

File tree

4 files changed

+10
-26
lines changed

4 files changed

+10
-26
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
TEMP_DIR=$(mktemp -d)
2828
cd $TEMP_DIR
2929
nix flake init -t $FLAKE
30-
nix develop -c , fmt
30+
nix develop --override-input mission-control path:${FLAKE} -c , fmt
3131
- name: Flake checks 🧪
3232
run: |
3333
# Because 'nix flake check' is not system-aware

example/flake.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
mission-control.scripts = {
1717
hello = {
1818
description = "Say Hello";
19-
command = "echo Hello";
19+
exec = "echo Hello";
2020
};
2121
fmt = {
2222
description = "Format the top-level Nix files";
23-
command = "${lib.getExe pkgs.nixpkgs-fmt} ./*.nix";
23+
exec = "${lib.getExe pkgs.nixpkgs-fmt} ./*.nix";
2424
category = "Tools";
2525
};
2626
ponysay = {
27-
package = pkgs.ponysay;
27+
exec = pkgs.ponysay;
2828
};
2929
};
3030
devShells.default =

nix/flake-module.nix

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,11 @@ in
2929
'';
3030
default = "Commands";
3131
};
32-
# The following are enum options
33-
command = mkOption {
34-
type = types.nullOr types.str;
35-
description = lib.mdDoc ''
36-
The command or script to run
37-
38-
When setting this option, the 'package' option must not also be set.
39-
'';
40-
default = null;
41-
};
42-
package = mkOption {
43-
type = types.nullOr types.package;
32+
exec = mkOption {
33+
type = types.oneOf [ types.str types.package ];
4434
description = lib.mdDoc ''
45-
The Nix package to run as the script.
46-
47-
When setting this option, the 'command' option must not also be set.
35+
The script or package to run
4836
'';
49-
default = null;
5037
};
5138
};
5239
};

nix/wrapper.nix

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ let
44
mkCommand = name: v:
55
let
66
drv =
7-
if v.package == null
8-
then pkgs.writeShellApplication { inherit name; text = v.command; }
9-
else
10-
if v.command == null
11-
then v.package
12-
else builtins.throw "misson-control.scripts.${name}: Both 'package' and 'command' options are set. You must set exactly one of them.";
7+
if builtins.typeOf v.exec == "string"
8+
then pkgs.writeShellApplication { inherit name; text = v.exec; }
9+
else v.exec;
1310
in
1411
drv.overrideAttrs (oa: {
1512
meta.description =

0 commit comments

Comments
 (0)