Created options; Moved tailscale to network folder; Disabled networkmanager wait online; Added repl command; updated firefox interface; other smaller stuff
This commit is contained in:
parent
8d59cbf644
commit
c087c07d02
37 changed files with 542 additions and 255 deletions
26
home/shell/repl/default.nix
Normal file
26
home/shell/repl/default.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# copied from https://github.com/fufexan/dotfiles/blob/main/pkgs/repl/default.nix
|
||||
{pkgs, ...}: let
|
||||
repl = ./lib.nix;
|
||||
example = command: desc: ''\n\u001b[33m ${command}\u001b[0m - ${desc}'';
|
||||
in {
|
||||
home.packages = [
|
||||
(pkgs.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 $(${pkgs.coreutils}/bin/readlink -f $1 | ${pkgs.gnused}/bin/sed 's|/flake.nix||') ${repl}
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
'')
|
||||
];
|
||||
}
|
||||
50
home/shell/repl/lib.nix
Normal file
50
home/shell/repl/lib.nix
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
# Copied from https://github.com/fufexan/dotfiles/blob/main/lib/repl.nix
|
||||
{
|
||||
flakePath ? null,
|
||||
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);}
|
||||
Loading…
Add table
Add a link
Reference in a new issue