feat: module recorder option

This commit is contained in:
Gustavo "Guz" L. de Mello
2024-05-30 22:05:27 -03:00
parent eb850e5823
commit a5f1c98b54
2 changed files with 58 additions and 18 deletions

View File

@@ -106,7 +106,9 @@ to use it on NixOS **using flakes**:
#### Installation methods
##### Install as a NixOS module
##### Install as a module
###### NixOS
```nix
# configuration.nix
{ inputs, ... }: {
@@ -118,7 +120,7 @@ to use it on NixOS **using flakes**:
}
```
##### Install as a Home Manager module
###### Home Manager
```nix
# home.nix
{ inputs, ... }: {
@@ -130,6 +132,16 @@ to use it on NixOS **using flakes**:
}
```
###### Configuration
```nix
# configration.nix or home.nix
programs.rec-sh.enable = true; # enables/installs the binary to your PATH
# Path to the recorder binary, default to wf-recorder. Can be null to unset the RECSH_RECORDER variable.
programs.rec-sh.recorder = "${pkgs.wf-recorder}/bin/wf-recorder"
```
##### Install as a package
```nix
# configuration.nix

View File

@@ -8,11 +8,19 @@
,
}:
let
package = { pkgs, ... }:
package =
{ pkgs
, recorder
, ...
}:
pkgs.writeShellScriptBin "rec-sh" ''
function slurp() { ${pkgs.slurp}/bin/slurp "$@"; }
function ffmpeg() { ${pkgs.ffmpeg}/bin/ffmpeg "$@"; }
function wf-recorder() { ${pkgs.wf-recorder}/bin/wf-recorder "$@"; }
${
if (builtins.isNull recorder)
then ""
else "RECSH_RECORDER=${recorder}"
}
${builtins.readFile ./rec.sh}
'';
@@ -36,9 +44,13 @@
options.programs.rec-sh = options { inherit config lib pkgs; };
config = with lib;
mkIf cfg.enable {
home.packages = [
self.packages.${pkgs.system}.rec-sh
];
home.packages =
let
recorder = cfg.recorder;
in
[
(package { inherit pkgs recorder; })
];
};
};
@@ -55,9 +67,13 @@
options.programs.rec-sh = options { inherit config lib pkgs; };
config = with lib;
mkIf cfg.enable {
environment.systemPackages = [
self.packages.${pkgs.system}.rec-sh
];
environment.systemPackages =
let
recorder = cfg.recorder;
in
[
(package { inherit pkgs recorder; })
];
};
};
@@ -70,6 +86,10 @@
with lib;
with lib.types; {
enable = mkEnableOption "";
recorder = mkOption {
type = nullOr str;
default = "${pkgs.wf-recorder}/bin/wf-recorder";
};
};
systems = [
@@ -80,17 +100,25 @@
{
packages =
forAllSystems
(system: pkgs: {
rec-sh = package { inherit pkgs; };
default = self.packages.${system}.rec-sh;
});
(system: pkgs:
let
recorder = null;
in
{
rec-sh = package { inherit pkgs recorder; };
default = self.packages.${system}.rec-sh;
});
legacyPackages =
forAllSystems
(system: pkgs: {
rec-sh = package { inherit pkgs; };
default = self.legacyPackages.${system}.rec-sh;
});
(system: pkgs:
let
recorder = null;
in
{
rec-sh = package { inherit pkgs recorder; };
default = self.legacyPackages.${system}.rec-sh;
});
nixosModules = {
rec-sh = nixosModule;