mirror of
https://github.com/gytis-ivaskevicius/flake-utils-plus.git
synced 2024-08-17 03:50:24 +03:00
Merge pull request #139 from gytis-ivaskevicius/implement-fup-repl-blueprint
feat: implement fup-repl blueprint #127
This commit is contained in:
commit
f726afcdf0
@ -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
20
lib/fup-repl.nix
Normal 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
|
||||
''
|
@ -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
|
||||
'';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user