chore: update flake.lock

This commit is contained in:
matt1432 2023-12-02 14:32:48 -05:00
parent 384fe2a6e1
commit aab8ce92c3
5 changed files with 90 additions and 9 deletions

View file

@ -1,21 +1,28 @@
{lib, pkgs, ...}: let {
lib,
pkgs,
...
}: let
mkPackage = name: v: { mkPackage = name: v: {
${name} = pkgs.callPackage ./${name} {}; ${name} = pkgs.callPackage ./${name} {};
}; };
rmNotPackage = name: value: rmNotPackage = name: value:
value == "directory" && value
builtins.pathExists ./${name}/default.nix; == "directory"
&& builtins.pathExists ./${name}/default.nix;
packages = lib.attrsets.filterAttrs rmNotPackage (builtins.readDir ./.); packages = lib.attrsets.filterAttrs rmNotPackage (builtins.readDir ./.);
pkgSet = lib.attrsets.concatMapAttrs mkPackage packages; pkgSet = lib.attrsets.concatMapAttrs mkPackage packages;
in { in {
imports = [{ imports = [
{
options.customPkgs = lib.mkOption { options.customPkgs = lib.mkOption {
type = lib.types.attrs; type = lib.types.attrs;
}; };
}]; }
];
customPkgs = pkgSet; customPkgs = pkgSet;
} }

View file

@ -0,0 +1,25 @@
# modified from https://github.com/gytis-ivaskevicius/flake-utils/plus
{
coreutils,
gnused,
writeShellScriptBin,
}: let
repl = ./repl.nix;
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}
else
nix repl --arg flakePath $(${coreutils}/bin/readlink -f $1 | ${gnused}/bin/sed 's|/flake.nix||') ${repl}
fi
;;
esac
''

49
common/pkgs/repl/repl.nix Normal file
View file

@ -0,0 +1,49 @@
{
flakePath ? ../../../.,
hostnamePath ? "/etc/hostname",
registryPath ? /etc/nix/registry.json,
}: let
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 =
if pathExists hostnamePath
then head (match "([a-zA-Z0-9\\-]+)\n" (readFile hostnamePath))
else "";
nixpkgsFromInputsPath = flake.inputs.nixpkgs.outPath or "";
nixpkgs =
flake.pkgs.${currentSystem}.nixpkgs
or (
if nixpkgsFromInputsPath != ""
then import nixpkgsFromInputsPath {}
else {}
);
nixpkgsOutput = removeAttrs (nixpkgs // nixpkgs.lib or {}) ["options" "config"];
in
{inherit flake;}
// flake
// builtins
// (flake.nixosConfigurations or {})
// flake.nixosConfigurations.${hostname} or {}
// nixpkgsOutput
// {getFlake = path: getFlake (toString path);}

Binary file not shown.