From e435da56381f5e4b1ca4e636a5241fced164a2a3 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Mon, 19 Dec 2022 10:18:56 -0500 Subject: [PATCH 1/2] Use singular option for command and package --- example/flake.nix | 6 +++--- nix/flake-module.nix | 19 +++---------------- nix/wrapper.nix | 9 +++------ 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/example/flake.nix b/example/flake.nix index 1a0c2a7..68171ba 100644 --- a/example/flake.nix +++ b/example/flake.nix @@ -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 = diff --git a/nix/flake-module.nix b/nix/flake-module.nix index d340e76..1ffbb00 100644 --- a/nix/flake-module.nix +++ b/nix/flake-module.nix @@ -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; }; }; }; diff --git a/nix/wrapper.nix b/nix/wrapper.nix index 6d525a7..200eb92 100644 --- a/nix/wrapper.nix +++ b/nix/wrapper.nix @@ -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 = From e625943e88664c48190603a555503d8f00e02d25 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Mon, 19 Dec 2022 10:35:25 -0500 Subject: [PATCH 2/2] ci: make template check use current flake --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index abab256..eb4bc37 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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