refactor: legacyPackages
This commit is contained in:
@@ -49,8 +49,8 @@
|
|||||||
pkgs,
|
pkgs,
|
||||||
}: {
|
}: {
|
||||||
packages.${system} = import ./package { inherit system pkgs self; };
|
packages.${system} = import ./package { inherit system pkgs self; };
|
||||||
legacyPackages.${system} = import nixpkgs { inherit system overlays; };
|
legacyPackages.${system} = import ./legacy { inherit system pkgs self; };
|
||||||
devShells.${system} = import ./devshell { inherit self system pkgs; };
|
devShells.${system} = import ./devshell { inherit system pkgs self; };
|
||||||
nixosConfigurations = {
|
nixosConfigurations = {
|
||||||
"devvm-manual|${system}" = import ./nixos/system/devvm-manual/default.nix
|
"devvm-manual|${system}" = import ./nixos/system/devvm-manual/default.nix
|
||||||
{ inherit flake self inputs system; };
|
{ inherit flake self inputs system; };
|
||||||
|
|||||||
4
legacy/default.nix
Normal file
4
legacy/default.nix
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{ self, system, pkgs }:
|
||||||
|
{
|
||||||
|
writers = pkgs.callPackage ./writer { };
|
||||||
|
}
|
||||||
51
legacy/writer/default.nix
Normal file
51
legacy/writer/default.nix
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
{
|
||||||
|
lib,
|
||||||
|
writers,
|
||||||
|
gcc,
|
||||||
|
}: let
|
||||||
|
writeC = name: argsOrScript:
|
||||||
|
if lib.isAttrs argsOrScript && !lib.isDerivation argsOrScript
|
||||||
|
then
|
||||||
|
writers.makeBinWriter (
|
||||||
|
argsOrScript
|
||||||
|
// {
|
||||||
|
compileScript = ''
|
||||||
|
# Force gcc to treat the input file as C code
|
||||||
|
${gcc}/bin/gcc -fsyntax-only -xc $contentPath
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Syntax check failed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
${gcc}/bin/gcc -xc -o $out $contentPath
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
)
|
||||||
|
name
|
||||||
|
else
|
||||||
|
writers.makeBinWriter {
|
||||||
|
compileScript = ''
|
||||||
|
# Force gcc to treat the input file as C code
|
||||||
|
${gcc}/bin/gcc -fsyntax-only -xc $contentPath
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Syntax check failed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
${gcc}/bin/gcc -xc -o $out $contentPath
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
name
|
||||||
|
argsOrScript;
|
||||||
|
writeMinC = name: includes: body:
|
||||||
|
writeC name ''
|
||||||
|
${builtins.concatStringsSep "\n" (map (h: "#include " + h) includes)}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
${body}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
in {
|
||||||
|
writeCBin = name: writeC "/bin/${name}";
|
||||||
|
writeC = writeC;
|
||||||
|
writeMinCBin = name: includes: body: writeMinC "/bin/${name}" includes body;
|
||||||
|
writeMinC = writeMinC;
|
||||||
|
}
|
||||||
150
legacy/writer/writeDashApplication.nix
Normal file
150
legacy/writer/writeDashApplication.nix
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
{
|
||||||
|
/*
|
||||||
|
The name of the script to write.
|
||||||
|
|
||||||
|
Type: String
|
||||||
|
*/
|
||||||
|
name,
|
||||||
|
/*
|
||||||
|
The shell script's text, not including a shebang.
|
||||||
|
|
||||||
|
Type: String
|
||||||
|
*/
|
||||||
|
text,
|
||||||
|
/*
|
||||||
|
Inputs to add to the shell script's `$PATH` at runtime.
|
||||||
|
|
||||||
|
Type: [String|Derivation]
|
||||||
|
*/
|
||||||
|
runtimeInputs ? [ ],
|
||||||
|
/*
|
||||||
|
Extra environment variables to set at runtime.
|
||||||
|
|
||||||
|
Type: AttrSet
|
||||||
|
*/
|
||||||
|
runtimeEnv ? null,
|
||||||
|
/*
|
||||||
|
`stdenv.mkDerivation`'s `meta` argument.
|
||||||
|
|
||||||
|
Type: AttrSet
|
||||||
|
*/
|
||||||
|
meta ? { },
|
||||||
|
/*
|
||||||
|
`stdenv.mkDerivation`'s `passthru` argument.
|
||||||
|
|
||||||
|
Type: AttrSet
|
||||||
|
*/
|
||||||
|
passthru ? { },
|
||||||
|
/*
|
||||||
|
The `checkPhase` to run. Defaults to `shellcheck` on supported
|
||||||
|
platforms and `bash -n`.
|
||||||
|
|
||||||
|
The script path will be given as `$target` in the `checkPhase`.
|
||||||
|
|
||||||
|
Type: String
|
||||||
|
*/
|
||||||
|
checkPhase ? null,
|
||||||
|
/*
|
||||||
|
Checks to exclude when running `shellcheck`, e.g. `[ "SC2016" ]`.
|
||||||
|
|
||||||
|
See <https://www.shellcheck.net/wiki/> for a list of checks.
|
||||||
|
|
||||||
|
Type: [String]
|
||||||
|
*/
|
||||||
|
excludeShellChecks ? [ ],
|
||||||
|
/*
|
||||||
|
Extra command-line flags to pass to ShellCheck.
|
||||||
|
|
||||||
|
Type: [String]
|
||||||
|
*/
|
||||||
|
extraShellCheckFlags ? [ ],
|
||||||
|
/*
|
||||||
|
Bash options to activate with `set -o` at the start of the script.
|
||||||
|
|
||||||
|
Defaults to `[ "errexit" "nounset" "pipefail" ]`.
|
||||||
|
|
||||||
|
Type: [String]
|
||||||
|
*/
|
||||||
|
bashOptions ? [
|
||||||
|
"errexit"
|
||||||
|
"nounset"
|
||||||
|
"pipefail"
|
||||||
|
],
|
||||||
|
/*
|
||||||
|
Extra arguments to pass to `stdenv.mkDerivation`.
|
||||||
|
|
||||||
|
:::{.caution}
|
||||||
|
Certain derivation attributes are used internally,
|
||||||
|
overriding those could cause problems.
|
||||||
|
:::
|
||||||
|
|
||||||
|
Type: AttrSet
|
||||||
|
*/
|
||||||
|
derivationArgs ? { },
|
||||||
|
/*
|
||||||
|
Whether to inherit the current `$PATH` in the script.
|
||||||
|
|
||||||
|
Type: Bool
|
||||||
|
*/
|
||||||
|
inheritPath ? true,
|
||||||
|
}:
|
||||||
|
writeTextFile {
|
||||||
|
inherit
|
||||||
|
name
|
||||||
|
meta
|
||||||
|
passthru
|
||||||
|
derivationArgs
|
||||||
|
;
|
||||||
|
executable = true;
|
||||||
|
destination = "/bin/${name}";
|
||||||
|
allowSubstitutes = true;
|
||||||
|
preferLocalBuild = false;
|
||||||
|
text =
|
||||||
|
''
|
||||||
|
#!${dash}/bin/dash
|
||||||
|
${lib.concatMapStringsSep "\n" (option: "set -o ${option}") bashOptions}
|
||||||
|
''
|
||||||
|
+ lib.optionalString (runtimeEnv != null) (
|
||||||
|
lib.concatStrings (
|
||||||
|
lib.mapAttrsToList (name: value: ''
|
||||||
|
${lib.toShellVar name value}
|
||||||
|
export ${name}
|
||||||
|
'') runtimeEnv
|
||||||
|
)
|
||||||
|
)
|
||||||
|
+ lib.optionalString (runtimeInputs != [ ]) ''
|
||||||
|
|
||||||
|
export PATH="${lib.makeBinPath runtimeInputs}${lib.optionalString inheritPath ":$PATH"}"
|
||||||
|
''
|
||||||
|
+ ''
|
||||||
|
|
||||||
|
${text}
|
||||||
|
'';
|
||||||
|
|
||||||
|
checkPhase =
|
||||||
|
let
|
||||||
|
excludeFlags = lib.optionals (excludeShellChecks != [ ]) [
|
||||||
|
"--exclude"
|
||||||
|
(lib.concatStringsSep "," excludeShellChecks)
|
||||||
|
];
|
||||||
|
# GHC (=> shellcheck) isn't supported on some platforms (such as risc-v)
|
||||||
|
# but we still want to use writeShellApplication on those platforms
|
||||||
|
shellcheckCommand = lib.optionalString shellcheck-minimal.compiler.bootstrapAvailable ''
|
||||||
|
# use shellcheck which does not include docs
|
||||||
|
# pandoc takes long to build and documentation isn't needed for just running the cli
|
||||||
|
${lib.getExe shellcheck-minimal} ${
|
||||||
|
lib.escapeShellArgs (excludeFlags ++ extraShellCheckFlags)
|
||||||
|
} "$target"
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
if checkPhase == null then
|
||||||
|
''
|
||||||
|
runHook preCheck
|
||||||
|
#dryrun
|
||||||
|
${dash}/bin/dash -n -O extglob "$target"
|
||||||
|
${shellcheckCommand}
|
||||||
|
runHook postCheck
|
||||||
|
''
|
||||||
|
else
|
||||||
|
checkPhase;
|
||||||
|
};
|
||||||
@@ -24,6 +24,15 @@ in {
|
|||||||
urls to check
|
urls to check
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
authFile = lib.mkOption {
|
||||||
|
type = lib.types.path;
|
||||||
|
example = ''
|
||||||
|
config.sops.secrets."name-of-service/sentinèlla-probe".path
|
||||||
|
'';
|
||||||
|
description = ''
|
||||||
|
file with lines: user:pass
|
||||||
|
'';
|
||||||
|
};
|
||||||
volumes = lib.mkOption {
|
volumes = lib.mkOption {
|
||||||
type = lib.types.port;
|
type = lib.types.port;
|
||||||
description = ''
|
description = ''
|
||||||
@@ -44,9 +53,10 @@ in {
|
|||||||
description = ''
|
description = ''
|
||||||
in case when you do not want show configurations in repository
|
in case when you do not want show configurations in repository
|
||||||
```
|
```
|
||||||
VOLUMES=
|
VOLUMES= # default: none
|
||||||
URLS=
|
URLS= # default: all from df -P
|
||||||
PORT=
|
PORT=
|
||||||
|
AUTH_FILE= # lines: user:pass
|
||||||
```
|
```
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,7 +9,10 @@
|
|||||||
name = builtins.baseNameOf ./.;
|
name = builtins.baseNameOf ./.;
|
||||||
|
|
||||||
in self.lib.nixpkgs-lib.nixosSystem {
|
in self.lib.nixpkgs-lib.nixosSystem {
|
||||||
inherit (self.legacyPackages."${system}") pkgs;
|
pkgs = import inputs.nixpkgs-25-05 {
|
||||||
|
inherit system;
|
||||||
|
overlays = [ self.overlays.default ];
|
||||||
|
};
|
||||||
modules = [
|
modules = [
|
||||||
{ networking.hostName = name; }
|
{ networking.hostName = name; }
|
||||||
(import ./${name}.nix { inherit flake self inputs; })
|
(import ./${name}.nix { inherit flake self inputs; })
|
||||||
|
|||||||
@@ -9,7 +9,10 @@
|
|||||||
name = builtins.baseNameOf ./.;
|
name = builtins.baseNameOf ./.;
|
||||||
|
|
||||||
in self.lib.nixpkgs-lib.nixosSystem {
|
in self.lib.nixpkgs-lib.nixosSystem {
|
||||||
inherit (self.legacyPackages."${system}") pkgs;
|
pkgs = import inputs.nixpkgs-25-05 {
|
||||||
|
inherit system;
|
||||||
|
overlays = [ self.overlays.default ];
|
||||||
|
};
|
||||||
modules = [
|
modules = [
|
||||||
{ networking.hostName = name; }
|
{ networking.hostName = name; }
|
||||||
(import ./${name}.nix { inherit flake self inputs; })
|
(import ./${name}.nix { inherit flake self inputs; })
|
||||||
|
|||||||
@@ -9,7 +9,10 @@
|
|||||||
name = builtins.baseNameOf ./.;
|
name = builtins.baseNameOf ./.;
|
||||||
|
|
||||||
in self.lib.nixpkgs-lib.nixosSystem {
|
in self.lib.nixpkgs-lib.nixosSystem {
|
||||||
inherit (self.legacyPackages."${system}") pkgs;
|
pkgs = import inputs.nixpkgs-25-05 {
|
||||||
|
inherit system;
|
||||||
|
overlays = [ self.overlays.default ];
|
||||||
|
};
|
||||||
modules = [
|
modules = [
|
||||||
{ networking.hostName = name; }
|
{ networking.hostName = name; }
|
||||||
(import ./${name}.nix { inherit flake self inputs; })
|
(import ./${name}.nix { inherit flake self inputs; })
|
||||||
|
|||||||
@@ -2,78 +2,31 @@
|
|||||||
lib = nixpkgs.lib;
|
lib = nixpkgs.lib;
|
||||||
in final: prev: (
|
in final: prev: (
|
||||||
let
|
let
|
||||||
hectic-packages = self.packages.${prev.system};
|
packages = self.packages.${prev.system};
|
||||||
|
legacyPackages = self.legacyPackages.${prev.system};
|
||||||
in {
|
in {
|
||||||
hectic = hectic-packages;
|
hectic = packages;
|
||||||
postgresql_17 = prev.postgresql_17 // {pkgs = prev.postgresql_17.pkgs // {
|
postgresql_17 = prev.postgresql_17 // {pkgs = prev.postgresql_17.pkgs // {
|
||||||
http = hectic-packages.pg-17-ext-http;
|
http = packages.pg-17-ext-http;
|
||||||
pg_smtp_client = hectic-packages.pg-17-ext-smtp-client;
|
pg_smtp_client = packages.pg-17-ext-smtp-client;
|
||||||
plhaskell = hectic-packages.pg-17-ext-plhaskell;
|
plhaskell = packages.pg-17-ext-plhaskell;
|
||||||
plsh = hectic-packages.pg-17-ext-plsh;
|
plsh = packages.pg-17-ext-plsh;
|
||||||
hemar = hectic-packages.pg-17-ext-hemar;
|
hemar = packages.pg-17-ext-hemar;
|
||||||
};};
|
};};
|
||||||
postgresql_16 = prev.postgresql_16 // {pkgs = prev.postgresql_16.pkgs // {
|
postgresql_16 = prev.postgresql_16 // {pkgs = prev.postgresql_16.pkgs // {
|
||||||
http = hectic-packages.pg-16-ext-http;
|
http = packages.pg-16-ext-http;
|
||||||
pg_smtp_client = hectic-packages.pg-16-ext-smtp-client;
|
pg_smtp_client = packages.pg-16-ext-smtp-client;
|
||||||
plhaskell = hectic-packages.pg-16-ext-plhaskell;
|
plhaskell = packages.pg-16-ext-plhaskell;
|
||||||
plsh = hectic-packages.pg-16-ext-plsh;
|
plsh = packages.pg-16-ext-plsh;
|
||||||
hemar = hectic-packages.pg-16-ext-hemar;
|
hemar = packages.pg-16-ext-hemar;
|
||||||
};};
|
};};
|
||||||
postgresql_15 = prev.postgresql_15 // {pkgs = prev.postgresql_15.pkgs // {
|
postgresql_15 = prev.postgresql_15 // {pkgs = prev.postgresql_15.pkgs // {
|
||||||
http = hectic-packages.pg-15-ext-http;
|
http = packages.pg-15-ext-http;
|
||||||
pg_smtp_client = hectic-packages.pg-15-ext-smtp-client;
|
pg_smtp_client = packages.pg-15-ext-smtp-client;
|
||||||
plhaskell = hectic-packages.pg-15-ext-plhaskell;
|
plhaskell = packages.pg-15-ext-plhaskell;
|
||||||
plsh = hectic-packages.pg-15-ext-plsh;
|
plsh = packages.pg-15-ext-plsh;
|
||||||
hemar = hectic-packages.pg-15-ext-hemar;
|
hemar = packages.pg-15-ext-hemar;
|
||||||
};};
|
};};
|
||||||
writers = let
|
writers = prev.writers // legacyPackages.writers;
|
||||||
writeC = name: argsOrScript:
|
|
||||||
if lib.isAttrs argsOrScript && !lib.isDerivation argsOrScript
|
|
||||||
then
|
|
||||||
prev.writers.makeBinWriter (
|
|
||||||
argsOrScript
|
|
||||||
// {
|
|
||||||
compileScript = ''
|
|
||||||
# Force gcc to treat the input file as C code
|
|
||||||
${prev.gcc}/bin/gcc -fsyntax-only -xc $contentPath
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Syntax check failed"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
${prev.gcc}/bin/gcc -xc -o $out $contentPath
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
)
|
|
||||||
name
|
|
||||||
else
|
|
||||||
prev.writers.makeBinWriter {
|
|
||||||
compileScript = ''
|
|
||||||
# Force gcc to treat the input file as C code
|
|
||||||
${prev.gcc}/bin/gcc -fsyntax-only -xc $contentPath
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Syntax check failed"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
${prev.gcc}/bin/gcc -xc -o $out $contentPath
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
name
|
|
||||||
argsOrScript;
|
|
||||||
writeMinC = name: includes: body:
|
|
||||||
writeC name ''
|
|
||||||
${builtins.concatStringsSep "\n" (map (h: "#include " + h) includes)}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
${body}
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
prev.writers
|
|
||||||
// {
|
|
||||||
writeCBin = name: writeC "/bin/${name}";
|
|
||||||
writeC = writeC;
|
|
||||||
writeMinCBin = name: includes: body: writeMinC "/bin/${name}" includes body;
|
|
||||||
writeMinC = writeMinC;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
150
overlay/writeDashApplication.nix
Normal file
150
overlay/writeDashApplication.nix
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
{
|
||||||
|
/*
|
||||||
|
The name of the script to write.
|
||||||
|
|
||||||
|
Type: String
|
||||||
|
*/
|
||||||
|
name,
|
||||||
|
/*
|
||||||
|
The shell script's text, not including a shebang.
|
||||||
|
|
||||||
|
Type: String
|
||||||
|
*/
|
||||||
|
text,
|
||||||
|
/*
|
||||||
|
Inputs to add to the shell script's `$PATH` at runtime.
|
||||||
|
|
||||||
|
Type: [String|Derivation]
|
||||||
|
*/
|
||||||
|
runtimeInputs ? [ ],
|
||||||
|
/*
|
||||||
|
Extra environment variables to set at runtime.
|
||||||
|
|
||||||
|
Type: AttrSet
|
||||||
|
*/
|
||||||
|
runtimeEnv ? null,
|
||||||
|
/*
|
||||||
|
`stdenv.mkDerivation`'s `meta` argument.
|
||||||
|
|
||||||
|
Type: AttrSet
|
||||||
|
*/
|
||||||
|
meta ? { },
|
||||||
|
/*
|
||||||
|
`stdenv.mkDerivation`'s `passthru` argument.
|
||||||
|
|
||||||
|
Type: AttrSet
|
||||||
|
*/
|
||||||
|
passthru ? { },
|
||||||
|
/*
|
||||||
|
The `checkPhase` to run. Defaults to `shellcheck` on supported
|
||||||
|
platforms and `bash -n`.
|
||||||
|
|
||||||
|
The script path will be given as `$target` in the `checkPhase`.
|
||||||
|
|
||||||
|
Type: String
|
||||||
|
*/
|
||||||
|
checkPhase ? null,
|
||||||
|
/*
|
||||||
|
Checks to exclude when running `shellcheck`, e.g. `[ "SC2016" ]`.
|
||||||
|
|
||||||
|
See <https://www.shellcheck.net/wiki/> for a list of checks.
|
||||||
|
|
||||||
|
Type: [String]
|
||||||
|
*/
|
||||||
|
excludeShellChecks ? [ ],
|
||||||
|
/*
|
||||||
|
Extra command-line flags to pass to ShellCheck.
|
||||||
|
|
||||||
|
Type: [String]
|
||||||
|
*/
|
||||||
|
extraShellCheckFlags ? [ ],
|
||||||
|
/*
|
||||||
|
Bash options to activate with `set -o` at the start of the script.
|
||||||
|
|
||||||
|
Defaults to `[ "errexit" "nounset" "pipefail" ]`.
|
||||||
|
|
||||||
|
Type: [String]
|
||||||
|
*/
|
||||||
|
bashOptions ? [
|
||||||
|
"errexit"
|
||||||
|
"nounset"
|
||||||
|
"pipefail"
|
||||||
|
],
|
||||||
|
/*
|
||||||
|
Extra arguments to pass to `stdenv.mkDerivation`.
|
||||||
|
|
||||||
|
:::{.caution}
|
||||||
|
Certain derivation attributes are used internally,
|
||||||
|
overriding those could cause problems.
|
||||||
|
:::
|
||||||
|
|
||||||
|
Type: AttrSet
|
||||||
|
*/
|
||||||
|
derivationArgs ? { },
|
||||||
|
/*
|
||||||
|
Whether to inherit the current `$PATH` in the script.
|
||||||
|
|
||||||
|
Type: Bool
|
||||||
|
*/
|
||||||
|
inheritPath ? true,
|
||||||
|
}:
|
||||||
|
writeTextFile {
|
||||||
|
inherit
|
||||||
|
name
|
||||||
|
meta
|
||||||
|
passthru
|
||||||
|
derivationArgs
|
||||||
|
;
|
||||||
|
executable = true;
|
||||||
|
destination = "/bin/${name}";
|
||||||
|
allowSubstitutes = true;
|
||||||
|
preferLocalBuild = false;
|
||||||
|
text =
|
||||||
|
''
|
||||||
|
#!${dash}/bin/dash
|
||||||
|
${lib.concatMapStringsSep "\n" (option: "set -o ${option}") bashOptions}
|
||||||
|
''
|
||||||
|
+ lib.optionalString (runtimeEnv != null) (
|
||||||
|
lib.concatStrings (
|
||||||
|
lib.mapAttrsToList (name: value: ''
|
||||||
|
${lib.toShellVar name value}
|
||||||
|
export ${name}
|
||||||
|
'') runtimeEnv
|
||||||
|
)
|
||||||
|
)
|
||||||
|
+ lib.optionalString (runtimeInputs != [ ]) ''
|
||||||
|
|
||||||
|
export PATH="${lib.makeBinPath runtimeInputs}${lib.optionalString inheritPath ":$PATH"}"
|
||||||
|
''
|
||||||
|
+ ''
|
||||||
|
|
||||||
|
${text}
|
||||||
|
'';
|
||||||
|
|
||||||
|
checkPhase =
|
||||||
|
let
|
||||||
|
excludeFlags = lib.optionals (excludeShellChecks != [ ]) [
|
||||||
|
"--exclude"
|
||||||
|
(lib.concatStringsSep "," excludeShellChecks)
|
||||||
|
];
|
||||||
|
# GHC (=> shellcheck) isn't supported on some platforms (such as risc-v)
|
||||||
|
# but we still want to use writeShellApplication on those platforms
|
||||||
|
shellcheckCommand = lib.optionalString shellcheck-minimal.compiler.bootstrapAvailable ''
|
||||||
|
# use shellcheck which does not include docs
|
||||||
|
# pandoc takes long to build and documentation isn't needed for just running the cli
|
||||||
|
${lib.getExe shellcheck-minimal} ${
|
||||||
|
lib.escapeShellArgs (excludeFlags ++ extraShellCheckFlags)
|
||||||
|
} "$target"
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
if checkPhase == null then
|
||||||
|
''
|
||||||
|
runHook preCheck
|
||||||
|
#dryrun
|
||||||
|
${dash}/bin/dash -n -O extglob "$target"
|
||||||
|
${shellcheckCommand}
|
||||||
|
runHook postCheck
|
||||||
|
''
|
||||||
|
else
|
||||||
|
checkPhase;
|
||||||
|
};
|
||||||
@@ -241,8 +241,6 @@ in {
|
|||||||
nvim-alias = pkgs.callPackage ./nvim-alias.nix {};
|
nvim-alias = pkgs.callPackage ./nvim-alias.nix {};
|
||||||
bolt-unpack = pkgs.callPackage ./bolt-unpack.nix {};
|
bolt-unpack = pkgs.callPackage ./bolt-unpack.nix {};
|
||||||
nvim-pager = pkgs.callPackage ./nvim-pager.nix {};
|
nvim-pager = pkgs.callPackage ./nvim-pager.nix {};
|
||||||
printobstacle = pkgs.callPackage ./printobstacle.nix {};
|
|
||||||
printprogress = pkgs.callPackage ./printprogress.nix {};
|
|
||||||
colorize = pkgs.callPackage ./colorize.nix {};
|
colorize = pkgs.callPackage ./colorize.nix {};
|
||||||
github-gh-tl = pkgs.callPackage ./github/gh-tl.nix {};
|
github-gh-tl = pkgs.callPackage ./github/gh-tl.nix {};
|
||||||
supabase-with-env-collection = pkgs.callPackage ./supabase-with-env-collection.nix {};
|
supabase-with-env-collection = pkgs.callPackage ./supabase-with-env-collection.nix {};
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
{pkgs, ...}: let
|
|
||||||
name = "printobstacle";
|
|
||||||
in
|
|
||||||
pkgs.writeShellScriptBin "${name}" ''
|
|
||||||
printf "%s%s%s\n" "''${RED}" "$*" "''${RESET}"
|
|
||||||
''
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{pkgs, ...}: let
|
|
||||||
name = "printprogress";
|
|
||||||
in
|
|
||||||
pkgs.writeShellScriptBin "${name}" ''
|
|
||||||
printf "%s%s%s\n" "''${YELLOW}" "$*" "''${RESET}"
|
|
||||||
''
|
|
||||||
81
package/sentinèlla/base64.sh
Normal file
81
package/sentinèlla/base64.sh
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
mod="${1:?}"
|
||||||
|
|
||||||
|
case "$mod" in
|
||||||
|
encode)
|
||||||
|
printf '%s' "${2:?}" | od -An -t u1 | tr -s ' ' | tr -d '\n' | awk '
|
||||||
|
BEGIN {
|
||||||
|
A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
||||||
|
}
|
||||||
|
function dec2bin(n, r,len,pad) {
|
||||||
|
if (n==0) return "00000000"
|
||||||
|
while (n>0) {
|
||||||
|
r = (n%2) r
|
||||||
|
n = int(n/2)
|
||||||
|
}
|
||||||
|
return sprintf("%08s", r)
|
||||||
|
}
|
||||||
|
function bin2dec(s, i,d,r) {
|
||||||
|
r=0
|
||||||
|
for(i=1;i<=length(s);i++) {
|
||||||
|
d=substr(s,i,1)
|
||||||
|
r = r*2 + d
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
function buildbin(t, r) {
|
||||||
|
for(i=1;i<=NF;i+=1) {
|
||||||
|
#printf("%s | %s\n", dec2bin($i), $i)
|
||||||
|
r = sprintf("%s%s", r, dec2bin($i))
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
function base64(b, r,c) {
|
||||||
|
for(i=1;i<=length(b);i+=6) {
|
||||||
|
#printf("%s | %s\n", substr(b,i,6), bin2dec(substr(b,i,6)))
|
||||||
|
c = substr(A, bin2dec(substr(b,i,6))+1, 1)
|
||||||
|
r = sprintf("%s%s", r, c)
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
{
|
||||||
|
b=buildbin($1)
|
||||||
|
l=length(b)
|
||||||
|
lack = (6 - l % 6) % 6
|
||||||
|
for(i=1;i<=lack;i+=1) {
|
||||||
|
b = sprintf("%s0", b)
|
||||||
|
}
|
||||||
|
r = base64(b)
|
||||||
|
for(i=1;i<=lack/2;i+=1) {
|
||||||
|
r = sprintf("%s=", r)
|
||||||
|
}
|
||||||
|
print r
|
||||||
|
}
|
||||||
|
'
|
||||||
|
;;
|
||||||
|
decode)
|
||||||
|
printf '%b\n' "$(printf '%s' "${2:?}" | awk ' BEGIN {
|
||||||
|
A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
||||||
|
}
|
||||||
|
function dec2bin(n, r,len,pad) {
|
||||||
|
if (n==0) return "000000"
|
||||||
|
while (n>0) {
|
||||||
|
r = (n%2) r
|
||||||
|
n = int(n/2)
|
||||||
|
}
|
||||||
|
r = sprintf("%6s", r)
|
||||||
|
gsub(/ /,"0",r)
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
{
|
||||||
|
for(i=1;i<=length($1);i+=1) {
|
||||||
|
b=sprintf("%s%s", b, dec2bin(index(A, substr($1,i,1))-1))
|
||||||
|
}
|
||||||
|
for(i=1; i<=length(b); i+=8){
|
||||||
|
n=0
|
||||||
|
for(j=0;j<8;j++) n = n*2 + (substr(b,i+j,1)=="1")
|
||||||
|
printf "\\x%02X", n
|
||||||
|
}
|
||||||
|
}
|
||||||
|
')"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
{ symlinkJoin, writeShellApplication, socat, dash, hectic, curl }:
|
{ symlinkJoin, writeShellApplication, socat, dash, hectic, curl }:
|
||||||
let
|
let
|
||||||
|
base64 = writeShellApplication {
|
||||||
|
name = "base64";
|
||||||
|
runtimeInputs = [ ];
|
||||||
|
text = builtins.readFile ./base64.sh;
|
||||||
|
};
|
||||||
|
|
||||||
# TODO: writeDashApplication
|
# TODO: writeDashApplication
|
||||||
probe = writeShellApplication {
|
probe = writeShellApplication {
|
||||||
name = "probe";
|
name = "probe";
|
||||||
@@ -9,7 +15,7 @@ let
|
|||||||
|
|
||||||
probe-loop = writeShellApplication {
|
probe-loop = writeShellApplication {
|
||||||
name = "probe-loop";
|
name = "probe-loop";
|
||||||
runtimeInputs = [ ];
|
runtimeInputs = [ base64 ];
|
||||||
text = builtins.readFile ./probe-loop.sh;
|
text = builtins.readFile ./probe-loop.sh;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -11,91 +11,6 @@
|
|||||||
# TIMEOUT=5
|
# TIMEOUT=5
|
||||||
# AUTH_FILE="/path/htpasswd-like" # lines: user:pass
|
# AUTH_FILE="/path/htpasswd-like" # lines: user:pass
|
||||||
|
|
||||||
base64() {
|
|
||||||
local mod
|
|
||||||
mod="${1:?}"
|
|
||||||
|
|
||||||
case "$mod" in
|
|
||||||
encode)
|
|
||||||
printf '%s' "${2:?}" | od -An -t u1 | tr -s ' ' | tr -d '\n' | awk '
|
|
||||||
BEGIN {
|
|
||||||
A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
|
||||||
}
|
|
||||||
function dec2bin(n, r,len,pad) {
|
|
||||||
if (n==0) return "00000000"
|
|
||||||
while (n>0) {
|
|
||||||
r = (n%2) r
|
|
||||||
n = int(n/2)
|
|
||||||
}
|
|
||||||
return sprintf("%08s", r)
|
|
||||||
}
|
|
||||||
function bin2dec(s, i,d,r) {
|
|
||||||
r=0
|
|
||||||
for(i=1;i<=length(s);i++) {
|
|
||||||
d=substr(s,i,1)
|
|
||||||
r = r*2 + d
|
|
||||||
}
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
function buildbin(t, r) {
|
|
||||||
for(i=1;i<=NF;i+=1) {
|
|
||||||
#printf("%s | %s\n", dec2bin($i), $i)
|
|
||||||
r = sprintf("%s%s", r, dec2bin($i))
|
|
||||||
}
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
function base64(b, r,c) {
|
|
||||||
for(i=1;i<=length(b);i+=6) {
|
|
||||||
#printf("%s | %s\n", substr(b,i,6), bin2dec(substr(b,i,6)))
|
|
||||||
c = substr(A, bin2dec(substr(b,i,6))+1, 1)
|
|
||||||
r = sprintf("%s%s", r, c)
|
|
||||||
}
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
{
|
|
||||||
b=buildbin($1)
|
|
||||||
l=length(b)
|
|
||||||
lack = (6 - l % 6) % 6
|
|
||||||
for(i=1;i<=lack;i+=1) {
|
|
||||||
b = sprintf("%s0", b)
|
|
||||||
}
|
|
||||||
r = base64(b)
|
|
||||||
for(i=1;i<=lack/2;i+=1) {
|
|
||||||
r = sprintf("%s=", r)
|
|
||||||
}
|
|
||||||
print r
|
|
||||||
}
|
|
||||||
'
|
|
||||||
;;
|
|
||||||
decode)
|
|
||||||
printf '%b\n' "$(printf '%s' "${2:?}" | awk ' BEGIN {
|
|
||||||
A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
|
||||||
}
|
|
||||||
function dec2bin(n, r,len,pad) {
|
|
||||||
if (n==0) return "000000"
|
|
||||||
while (n>0) {
|
|
||||||
r = (n%2) r
|
|
||||||
n = int(n/2)
|
|
||||||
}
|
|
||||||
r = sprintf("%6s", r)
|
|
||||||
gsub(/ /,"0",r)
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
{
|
|
||||||
for(i=1;i<=length($1);i+=1) {
|
|
||||||
b=sprintf("%s%s", b, dec2bin(index(A, substr($1,i,1))-1))
|
|
||||||
}
|
|
||||||
for(i=1; i<=length(b); i+=8){
|
|
||||||
n=0
|
|
||||||
for(j=0;j<8;j++) n = n*2 + (substr(b,i+j,1)=="1")
|
|
||||||
printf "\\x%02X", n
|
|
||||||
}
|
|
||||||
}
|
|
||||||
')"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
: "${TIMEOUT:=5}"
|
: "${TIMEOUT:=5}"
|
||||||
: "${VOLUMES:=$(df -P | awk 'NR>1{print $6}')}"
|
: "${VOLUMES:=$(df -P | awk 'NR>1{print $6}')}"
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
#!/bin/dash
|
#!/bin/dash
|
||||||
|
|
||||||
|
TOKEN=8448534574:AAEvsdQqhUDu3RVRJWDGIVeqRmXlB0Dqn1Q
|
||||||
|
CHAT_ID=380055934
|
||||||
|
POLLING_INTERVAL_SEC=${POLLING_INTERVAL_SEC:-3}
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
curl -s -X POST "https://api.telegram.org/bot${TOKEN}/sendMessage" \
|
||||||
|
-d "chat_id=${CHAT_ID}" \
|
||||||
|
-d text="your message"
|
||||||
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user