chore: update flake.lock
This commit is contained in:
parent
384fe2a6e1
commit
aab8ce92c3
5 changed files with 90 additions and 9 deletions
|
@ -1,21 +1,28 @@
|
|||
{lib, pkgs, ...}: let
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
mkPackage = name: v: {
|
||||
${name} = pkgs.callPackage ./${name} {};
|
||||
};
|
||||
|
||||
rmNotPackage = name: value:
|
||||
value == "directory" &&
|
||||
builtins.pathExists ./${name}/default.nix;
|
||||
value
|
||||
== "directory"
|
||||
&& builtins.pathExists ./${name}/default.nix;
|
||||
|
||||
packages = lib.attrsets.filterAttrs rmNotPackage (builtins.readDir ./.);
|
||||
|
||||
pkgSet = lib.attrsets.concatMapAttrs mkPackage packages;
|
||||
in {
|
||||
imports = [{
|
||||
imports = [
|
||||
{
|
||||
options.customPkgs = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
};
|
||||
}];
|
||||
}
|
||||
];
|
||||
|
||||
customPkgs = pkgSet;
|
||||
}
|
||||
|
|
25
common/pkgs/repl/default.nix
Normal file
25
common/pkgs/repl/default.nix
Normal 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
49
common/pkgs/repl/repl.nix
Normal 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);}
|
BIN
flake.lock
BIN
flake.lock
Binary file not shown.
Loading…
Reference in a new issue