Skip to content

Commit

Permalink
Add description to script
Browse files Browse the repository at this point in the history
Just some metadata that can be useful in various contexts like enterShell for example.
  • Loading branch information
mmlb committed Dec 5, 2023
1 parent a7c4dd8 commit fb975e4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
23 changes: 23 additions & 0 deletions docs/scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,26 @@ Entering shell ...
"foo": "1"
}
```

Scripts can also have an optional description, which can be used in your `enterShell`.

```nix title="devenv.nix"
{ pkgs, ... }:
{
scripts.silly-example.exec = ''
${pkgs.curl}/bin/curl "https://httpbin.org/get?$1" | ${pkgs.jq}/bin/jq '.args'
'';
scripts.silly-example.exec = ''simple example script'';
enterShell = ''
echo
echo 🦾 Helper scripts you can run to make your development richer:
echo 🦾
sed -e 's| |••|g' -e 's|=| |' <<EOF | column -t | sed -e 's|^|🦾 |' -e 's|••| |g'
${lib.generators.toKeyValue {} (lib.mapAttrs (name: value: value.description) config.scripts)}
EOF
echo
'';
}
```

12 changes: 10 additions & 2 deletions src/modules/scripts.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{ pkgs, lib, config, ... }:

{ pkgs
, lib
, config
, ...
}:
let
types = lib.types;
scriptType = types.submodule ({ config, ... }: {
Expand All @@ -8,6 +11,11 @@ let
type = types.str;
description = "Bash code to execute when the script is run.";
};
description = lib.mkOption {
type = types.str;
description = "Description of the script.";
default = "";
};
};
});
# lib.hiPrioSet: prioritize scripts over plain packages
Expand Down

0 comments on commit fb975e4

Please sign in to comment.