Merge pull request #139 from gytis-ivaskevicius/implement-fup-repl-blueprint

feat: implement fup-repl blueprint #127
This commit is contained in:
Gytis Ivaskevicius 2023-10-02 23:57:00 +03:00 committed by GitHub
commit f726afcdf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 26 deletions

View File

@ -15,11 +15,16 @@
exportPackages = import ./lib/exportPackages.nix fupArgs;
genPkgOverlay = import ./lib/genPkgOverlay.nix;
internal-functions = import ./lib/internal-functions.nix;
overlay = import ./lib/overlay.nix;
overlay = final: prev: {
__dontExport = true;
fup-repl = final.callPackage ./lib/fup-repl.nix { };
};
in
rec {
inherit overlay;
blueprints.fup-repl = ./lib/fup-repl.nix;
nixosModules.autoGenFromInputs = import ./lib/options.nix;
darwinModules.autoGenFromInputs = import ./lib/options.nix;

20
lib/fup-repl.nix Normal file
View File

@ -0,0 +1,20 @@
{ writeShellScriptBin, coreutils, gnused }:
let
example = command: desc: ''\n\u001b[33m ${command}\u001b[0m - ${desc}'';
in
writeShellScriptBin "repl" ''
case "$1" in
"-h"|"--help"|"help")
printf "%b\n\e[4mUsage\e[0m: \
${example "repl" "Loads system flake if available."} \
${example "repl /path/to/flake.nix" "Loads specified flake."}\n"
;;
*)
if [ -z "$1" ]; then
nix repl ${./repl.nix}
else
nix repl --arg flakePath $(${coreutils}/bin/readlink -f $1 | ${gnused}/bin/sed 's|/flake.nix||') ${./repl.nix}
fi
;;
esac
''

View File

@ -1,25 +0,0 @@
final: prev:
let
example = command: desc: ''\n\u001b[33m ${command}\u001b[0m - ${desc}'';
in
{
__dontExport = true;
fup-repl = final.writeShellScriptBin "repl" ''
case "$1" in
"-h"|"--help"|"help")
printf "%b\n\e[4mUsage\e[0m: \
${example "repl" "Loads system flake if available."} \
${example "repl /path/to/flake.nix" "Loads specified flake."}\n"
;;
*)
if [ -z "$1" ]; then
nix repl ${./repl.nix}
else
nix repl --arg flakePath $(${final.coreutils}/bin/readlink -f $1 | ${final.gnused}/bin/sed 's|/flake.nix||') ${./repl.nix}
fi
;;
esac
'';
}