Compare commits

..

No commits in common. "1b528a15d07c350c7ebd52cc803f51c40f8bdbad" and "ef11b36f846607301d37d47bcb1f7ea3ce92153b" have entirely different histories.

3 changed files with 59 additions and 54 deletions

View file

@ -8,10 +8,12 @@
releaseVer = elemAt (match "^([^']*).*" (elemAt (splitString "version: '" (readFile "${piper-src}/meson.build")) 1)) 0; releaseVer = elemAt (match "^([^']*).*" (elemAt (splitString "version: '" (readFile "${piper-src}/meson.build")) 1)) 0;
in in
piper.overridePythonAttrs { piper.overrideAttrs rec {
pname = "piper"; pname = "piper";
version = "${releaseVer}+${piper-src.shortRev}"; version = "${releaseVer}+${piper-src.shortRev}";
name = "${pname}-${version}";
src = piper-src; src = piper-src;
mesonFlags = [ mesonFlags = [

View file

@ -2,40 +2,25 @@
{ {
coreutils, coreutils,
gnused, gnused,
ncurses, writeShellScriptBin,
writeShellApplication,
... ...
}: let }: let
repl = ./repl.nix; repl = ./repl.nix;
example = command: desc: ''\n$(tput setaf 3) ${command}$(tput sgr0) - ${desc}''; example = command: desc: ''\n\u001b[33m ${command}\u001b[0m - ${desc}'';
in in
writeShellApplication { writeShellScriptBin "repl" ''
name = "repl"; case "$1" in
runtimeInputs = [coreutils gnused ncurses];
text = ''
arg=''${1:-"."}
case "$arg" in
"-h"|"--help"|"help") "-h"|"--help"|"help")
# shellcheck disable=SC2059 printf "%b\n\e[4mUsage\e[0m: \
printf "\n\e[4mUsage\e[0m: \ ${example "repl" "Loads system flake if available."} \
${example "repl " "Loads system flake present at $(tput setaf 4)\\$FLAKE$(tput sgr0)."} \ ${example "repl /path/to/flake.nix" "Loads specified flake."}\n"
${example "repl <flake path>" "Loads specified flake."}\n"
;; ;;
*) *)
if [ -z "$arg" ]; then if [ -z "$1" ]; then
nix repl \ nix repl --arg flakePath $(${coreutils}/bin/readlink -f "$FLAKE") --file ${repl}
--arg flakePath "$(realpath "$FLAKE")" \
--file ${repl}
else else
nix repl \ nix repl --arg flakePath $(${coreutils}/bin/readlink -f $1 | ${gnused}/bin/sed 's|/flake.nix||') --file ${repl}
--arg flakePath "$(realpath "$arg" | sed 's|/flake.nix||')" \
--file ${repl}
fi fi
;; ;;
esac esac
''; ''
}

View file

@ -1,31 +1,49 @@
{ {
flakePath, flakePath ? null,
hostnamePath ? "/etc/hostname", hostnamePath ? "/etc/hostname",
registryPath ? /etc/nix/registry.json,
}: let }: let
inherit (builtins) currentSystem getFlake head match pathExists readFile removeAttrs; inherit (builtins) getFlake head match currentSystem readFile pathExists filter fromJSON;
selfFlake =
if pathExists registryPath
then filter (it: it.from.id == "self") (fromJSON (readFile registryPath)).flakes
else [];
flakePath' =
toString
(
if flakePath != null
then flakePath
else if selfFlake != []
then (head selfFlake).to.path
else "/etc/nixos"
);
flake =
if pathExists flakePath'
then getFlake flakePath'
else {};
hostname = hostname =
if pathExists hostnamePath if pathExists hostnamePath
then head (match "([a-zA-Z0-9\\-]+)\n" (readFile hostnamePath)) then head (match "([a-zA-Z0-9\\-]+)\n" (readFile hostnamePath))
else ""; else "";
self = nixpkgsFromInputsPath = flake.inputs.nixpkgs.outPath or "";
if pathExists flakePath nixpkgs =
then flake.pkgs.${currentSystem}.nixpkgs
removeAttrs (getFlake (toString flakePath)) [ or (
# If you use flakegen, these take a lot of space if nixpkgsFromInputsPath != ""
"nextFlake" then import nixpkgsFromInputsPath {}
"nextFlakeSource" else {}
] );
else {};
pkgs = self.inputs.nixpkgs.legacyPackages.${currentSystem} or {}; nixpkgsOutput = removeAttrs (nixpkgs // nixpkgs.lib or {}) ["options" "config"];
lib =
if pkgs != {}
then {inherit (pkgs) lib;}
else {};
in in
{inherit lib pkgs self;} {inherit flake;}
// self.nixosConfigurations.${hostname} // flake
or self.nixOnDroidConfigurations.default // builtins
or {} // (flake.nixosConfigurations or {})
// flake.nixosConfigurations.${hostname} or {}
// nixpkgsOutput
// {getFlake = path: getFlake (toString path);}