Skip to content

Commit

Permalink
Merge pull request #16 from Platonic-Systems/exec
Browse files Browse the repository at this point in the history
Use singular option for command and package
  • Loading branch information
srid authored Dec 19, 2022
2 parents 4b43702 + e625943 commit a562943
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
TEMP_DIR=$(mktemp -d)
cd $TEMP_DIR
nix flake init -t $FLAKE
nix develop -c , fmt
nix develop --override-input mission-control path:${FLAKE} -c , fmt
- name: Flake checks 🧪
run: |
# Because 'nix flake check' is not system-aware
Expand Down
6 changes: 3 additions & 3 deletions example/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
mission-control.scripts = {
hello = {
description = "Say Hello";
command = "echo Hello";
exec = "echo Hello";
};
fmt = {
description = "Format the top-level Nix files";
command = "${lib.getExe pkgs.nixpkgs-fmt} ./*.nix";
exec = "${lib.getExe pkgs.nixpkgs-fmt} ./*.nix";
category = "Tools";
};
ponysay = {
package = pkgs.ponysay;
exec = pkgs.ponysay;
};
};
devShells.default =
Expand Down
19 changes: 3 additions & 16 deletions nix/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,11 @@ in
'';
default = "Commands";
};
# The following are enum options
command = mkOption {
type = types.nullOr types.str;
description = lib.mdDoc ''
The command or script to run
When setting this option, the 'package' option must not also be set.
'';
default = null;
};
package = mkOption {
type = types.nullOr types.package;
exec = mkOption {
type = types.oneOf [ types.str types.package ];
description = lib.mdDoc ''
The Nix package to run as the script.
When setting this option, the 'command' option must not also be set.
The script or package to run
'';
default = null;
};
};
};
Expand Down
9 changes: 3 additions & 6 deletions nix/wrapper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ let
mkCommand = name: v:
let
drv =
if v.package == null
then pkgs.writeShellApplication { inherit name; text = v.command; }
else
if v.command == null
then v.package
else builtins.throw "misson-control.scripts.${name}: Both 'package' and 'command' options are set. You must set exactly one of them.";
if builtins.typeOf v.exec == "string"
then pkgs.writeShellApplication { inherit name; text = v.exec; }
else v.exec;
in
drv.overrideAttrs (oa: {
meta.description =
Expand Down

0 comments on commit a562943

Please sign in to comment.