Create nushell application wrapper
Also move elements to `/nix/elements`.
This commit is contained in:
parent
b98774c1bf
commit
0fa23fdd05
18 changed files with 186 additions and 87 deletions
6
flake.lock
generated
6
flake.lock
generated
|
|
@ -548,11 +548,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_5": {
|
"nixpkgs_5": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1763049705,
|
"lastModified": 1763334038,
|
||||||
"narHash": "sha256-A5LS0AJZ1yDPTa2fHxufZN++n8MCmtgrJDtxFxrH4S8=",
|
"narHash": "sha256-LBVOyaH6NFzQ3X/c6vfMZ9k4SV2ofhpxeL9YnhHNJQQ=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "3acb677ea67d4c6218f33de0db0955f116b7588c",
|
"rev": "4c8cdd5b1a630e8f72c9dd9bf582b1afb3127d2c",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,11 @@
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
homes.users."christopher@beryllium".modules = with inputs; [
|
homes.users = {
|
||||||
quadlet.homeManagerModules.quadlet
|
"christopher@beryllium".modules = with inputs; [
|
||||||
];
|
quadlet.homeManagerModules.quadlet
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
# Configure nixpkgs when instantiating the package set
|
# Configure nixpkgs when instantiating the package set
|
||||||
# TODO: This is already specified elsewhere. Still needed here?
|
# TODO: This is already specified elsewhere. Still needed here?
|
||||||
|
|
@ -65,6 +67,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
|
# nixpkgs.url = "git+file:///home/christopher/code/opensource/nixpkgs";
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
|
||||||
unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
|
unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# Dev tools
|
# Dev tools
|
||||||
git
|
git
|
||||||
gh
|
gh
|
||||||
gitAndTools.git-absorb
|
git-absorb
|
||||||
delta # Diffing tool
|
delta # Diffing tool
|
||||||
onefetch # neofetch for git repos
|
onefetch # neofetch for git repos
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
vlc # Video player
|
vlc # Video player
|
||||||
obsidian # Note taking
|
obsidian # Note taking
|
||||||
calibre # eBook Manager
|
calibre # eBook Manager
|
||||||
onlyoffice-bin # libreoffice alternative
|
onlyoffice-desktopeditors # libreoffice alternative
|
||||||
filezilla # FTP Client
|
filezilla # FTP Client
|
||||||
orca-slicer # Bambu Lab Slicer + Control
|
orca-slicer # Bambu Lab Slicer + Control
|
||||||
krita # Drawing software
|
krita # Drawing software
|
||||||
|
|
@ -34,7 +34,6 @@
|
||||||
davinci-resolve # Video editor
|
davinci-resolve # Video editor
|
||||||
cider-2 # Apple music player
|
cider-2 # Apple music player
|
||||||
|
|
||||||
feh # Image viewer
|
|
||||||
xarchiver # Archive viewer/extractor
|
xarchiver # Archive viewer/extractor
|
||||||
zathura # Document viewer
|
zathura # Document viewer
|
||||||
evince # Document viewer
|
evince # Document viewer
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
{lib, ...}: {
|
{lib, ...} @ all: {
|
||||||
rootPath = ./..;
|
rootPath = ./..;
|
||||||
secret = name: ./../secrets/${name};
|
secret = name: ./../secrets/${name};
|
||||||
|
|
||||||
commonHomeModule = module: ./../homes/common + "/${module}";
|
commonHomeModule = module: ./../homes/common + "/${module}";
|
||||||
|
writeNushellApplication = import ./writeNushellApplication.nix {inherit lib;};
|
||||||
|
|
||||||
enabled = {enable = true;};
|
enabled = {enable = true;};
|
||||||
disabled = {enable = false;};
|
disabled = {enable = false;};
|
||||||
|
|
|
||||||
109
lib/writeNushellApplication.nix
Normal file
109
lib/writeNushellApplication.nix
Normal file
|
|
@ -0,0 +1,109 @@
|
||||||
|
{lib, ...}: pkgs: {
|
||||||
|
/*
|
||||||
|
The name of the script to write.
|
||||||
|
|
||||||
|
Type: String
|
||||||
|
*/
|
||||||
|
name,
|
||||||
|
/*
|
||||||
|
The shell script's text, not including a shebang.
|
||||||
|
|
||||||
|
Type: String
|
||||||
|
*/
|
||||||
|
text,
|
||||||
|
/*
|
||||||
|
Inputs to add to the shell script's `$PATH` at runtime.
|
||||||
|
|
||||||
|
Type: [String|Derivation]
|
||||||
|
*/
|
||||||
|
runtimeInputs ? [],
|
||||||
|
/*
|
||||||
|
Extra environment variables to set at runtime.
|
||||||
|
|
||||||
|
Type: AttrSet
|
||||||
|
*/
|
||||||
|
runtimeEnv ? null,
|
||||||
|
/*
|
||||||
|
`stdenv.mkDerivation`'s `meta` argument.
|
||||||
|
|
||||||
|
Type: AttrSet
|
||||||
|
*/
|
||||||
|
meta ? {},
|
||||||
|
/*
|
||||||
|
`stdenv.mkDerivation`'s `passthru` argument.
|
||||||
|
|
||||||
|
Type: AttrSet
|
||||||
|
*/
|
||||||
|
passthru ? {},
|
||||||
|
/*
|
||||||
|
The `checkPhase` to run. Defaults to `shellcheck` on supported
|
||||||
|
platforms and `bash -n`.
|
||||||
|
|
||||||
|
The script path will be given as `$target` in the `checkPhase`.
|
||||||
|
|
||||||
|
Type: String
|
||||||
|
*/
|
||||||
|
checkPhase ? null,
|
||||||
|
/*
|
||||||
|
Extra arguments to pass to `stdenv.mkDerivation`.
|
||||||
|
|
||||||
|
:::{.caution}
|
||||||
|
Certain derivation attributes are used internally,
|
||||||
|
overriding those could cause problems.
|
||||||
|
:::
|
||||||
|
|
||||||
|
Type: AttrSet
|
||||||
|
*/
|
||||||
|
derivationArgs ? {},
|
||||||
|
/*
|
||||||
|
Whether to inherit the current `$PATH` in the script.
|
||||||
|
|
||||||
|
Type: Bool
|
||||||
|
*/
|
||||||
|
inheritPath ? true,
|
||||||
|
}: let
|
||||||
|
nu = pkgs.nushell;
|
||||||
|
in
|
||||||
|
pkgs.writeTextFile {
|
||||||
|
inherit
|
||||||
|
name
|
||||||
|
meta
|
||||||
|
passthru
|
||||||
|
derivationArgs
|
||||||
|
;
|
||||||
|
executable = true;
|
||||||
|
destination = "/bin/${name}";
|
||||||
|
allowSubstitutes = true;
|
||||||
|
preferLocalBuild = false;
|
||||||
|
|
||||||
|
text =
|
||||||
|
''
|
||||||
|
#!${nu}${nu.shellPath}
|
||||||
|
|
||||||
|
use std/util "path add"
|
||||||
|
''
|
||||||
|
+ lib.optionalString (runtimeEnv != null) (
|
||||||
|
lib.concatMapAttrsStringSep "" (name: value: ''
|
||||||
|
$env.${lib.toShellVar name value}
|
||||||
|
export ${name}
|
||||||
|
'')
|
||||||
|
runtimeEnv
|
||||||
|
)
|
||||||
|
+ lib.optionalString (runtimeInputs != []) (''
|
||||||
|
${lib.optionalString (! inheritPath) "$env.PATH = []"}
|
||||||
|
''
|
||||||
|
+ lib.concatStringsSep ":" (map (path: ''
|
||||||
|
path add '${path}/bin'
|
||||||
|
'')
|
||||||
|
runtimeInputs))
|
||||||
|
+ text;
|
||||||
|
|
||||||
|
checkPhase =
|
||||||
|
if checkPhase == null
|
||||||
|
then ''
|
||||||
|
runHook preCheck
|
||||||
|
${nu}${nu.shellPath} -c "nu-check --debug $target"
|
||||||
|
runHook postCheck
|
||||||
|
''
|
||||||
|
else checkPhase;
|
||||||
|
}
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
git
|
git
|
||||||
gitleaks
|
gitleaks
|
||||||
just
|
just
|
||||||
|
nh
|
||||||
age
|
age
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,20 +4,23 @@
|
||||||
config,
|
config,
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
nix.settings = {
|
nix = {
|
||||||
# auto-optimize-store = true;
|
# Automatic cleanup
|
||||||
# builders-use-substitutes = true;
|
gc.automatic = true;
|
||||||
experimental-features = ["nix-command" "flakes"];
|
gc.dates = "weekly";
|
||||||
flake-registry = "/etc/nix/registry.json";
|
gc.options = "--delete-older-than 21d";
|
||||||
|
|
||||||
keep-derivations = true;
|
settings = {
|
||||||
keep-outputs = true;
|
# builders-use-substitutes = true;
|
||||||
|
experimental-features = ["nix-command" "flakes"];
|
||||||
|
flake-registry = "/etc/nix/registry.json";
|
||||||
|
|
||||||
trusted-users = ["root" "@wheel"];
|
keep-derivations = true;
|
||||||
|
keep-outputs = true;
|
||||||
|
|
||||||
substituters = [
|
trusted-users = ["root" "@wheel"];
|
||||||
"https://cache.nixos.org/"
|
substituters = ["https://cache.nixos.org/"];
|
||||||
];
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
nixpkgs = {
|
nixpkgs = {
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,7 @@ in {
|
||||||
./programs
|
./programs
|
||||||
./shell/aliases.nix
|
./shell/aliases.nix
|
||||||
./shell/prompt.nix
|
./shell/prompt.nix
|
||||||
./shell/nu
|
# ./shell/nu
|
||||||
./shell/fish
|
|
||||||
];
|
];
|
||||||
|
|
||||||
# add environment variables
|
# add environment variables
|
||||||
|
|
@ -22,6 +21,7 @@ in {
|
||||||
TERMINAL = "kitty";
|
TERMINAL = "kitty";
|
||||||
EDITOR = "hx";
|
EDITOR = "hx";
|
||||||
TERM = "xterm-color";
|
TERM = "xterm-color";
|
||||||
|
QT_QPA_PLATFORMTHEME = "qt5ct";
|
||||||
|
|
||||||
# auto-run programs using nix-index-database
|
# auto-run programs using nix-index-database
|
||||||
NIX_AUTO_RUN = "1";
|
NIX_AUTO_RUN = "1";
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{lib, ...}: {
|
{lib, ...}: {
|
||||||
home.shellAliases = {
|
home.shellAliases = {
|
||||||
elements = "just -f ~/.dotfiles/Justfile -d ~/.dotfiles";
|
elements = "just -f /nix/elements/Justfile -d /nix/elements";
|
||||||
elem = "elements";
|
elm = "elements";
|
||||||
g = "git";
|
g = "git";
|
||||||
copy = lib.mkDefault "wl-copy";
|
copy = lib.mkDefault "wl-copy";
|
||||||
inspect = "tmux -f ~/.tmux.inspect.conf new-session ssh inspect";
|
inspect = "tmux -f ~/.tmux.inspect.conf new-session ssh inspect";
|
||||||
|
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
{
|
|
||||||
pkgs,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}: {
|
|
||||||
programs.fish = {
|
|
||||||
enable = true;
|
|
||||||
shellAliases = config.home.shellAliases;
|
|
||||||
};
|
|
||||||
|
|
||||||
# config = ''
|
|
||||||
# export PATH="$HOME/code/hausgold/snippets/bin:$PATH"
|
|
||||||
# export PATH="$HOME/.bun/bin:$HOME/.npm/bin:$PATH"
|
|
||||||
|
|
||||||
# art()
|
|
||||||
# {
|
|
||||||
# if [ -f "./vendor/bin/sail" ];
|
|
||||||
# then
|
|
||||||
# ./vendor/bin/sail artisan "$@"
|
|
||||||
# else
|
|
||||||
# php artisan "$@"
|
|
||||||
# fi
|
|
||||||
# }
|
|
||||||
|
|
||||||
# sail()
|
|
||||||
# {
|
|
||||||
# if [ -f "./vendor/bin/sail" ];
|
|
||||||
# then
|
|
||||||
# ./vendor/bin/sail "$@"
|
|
||||||
# else
|
|
||||||
# echo "Sail is not installed. Run 'composer require laravel/sail' to install it."
|
|
||||||
# fi
|
|
||||||
# }
|
|
||||||
# '';
|
|
||||||
}
|
|
||||||
|
|
@ -23,6 +23,10 @@ in {
|
||||||
paste_actions = "no-op";
|
paste_actions = "no-op";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
actionAliases = {
|
||||||
|
"launch_current" = "launch --cwd current";
|
||||||
|
};
|
||||||
|
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
shell ${pkgs.nushell}/bin/nu
|
shell ${pkgs.nushell}/bin/nu
|
||||||
modify_font cell_height 7px
|
modify_font cell_height 7px
|
||||||
|
|
@ -30,5 +34,12 @@ in {
|
||||||
|
|
||||||
themeFile = "Catppuccin-Frappe";
|
themeFile = "Catppuccin-Frappe";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
xdg.configFile."kitty/open-actions.conf".text = ''
|
||||||
|
# Open all file links in helix in the current shell
|
||||||
|
protocol file
|
||||||
|
# mime text/*
|
||||||
|
action send_text normal,application hx "''${FILE_PATH}"\r
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,16 +37,17 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
services.desktopManager.plasma6.enable = true;
|
services.desktopManager.plasma6.enable = true;
|
||||||
services.displayManager.defaultSession = "plasma";
|
services.displayManager = {
|
||||||
# services.displayManager.sddm.enable = true;
|
defaultSession = "plasma";
|
||||||
# services.displayManager.sddm.wayland.enable = true;
|
|
||||||
# services.displayManager.sddm.wayland.compositor = "kwin";
|
# sddm = {
|
||||||
|
# enable = true;
|
||||||
|
# wayland.enable = true;
|
||||||
|
# };
|
||||||
|
};
|
||||||
|
|
||||||
# xdg.portal.extraPortals = [pkgs.xdg-desktop-portal-gtk];
|
# xdg.portal.extraPortals = [pkgs.xdg-desktop-portal-gtk];
|
||||||
|
|
||||||
security = {
|
security.polkit.enable = true;
|
||||||
polkit.enable = true;
|
|
||||||
pam.services.swaylock = {};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
{channels, ...}: final: prev: {
|
{channels, ...}: final: prev: {
|
||||||
# Pull the following packages from unstable instead
|
# Pull the following packages from unstable instead
|
||||||
inherit (channels.unstable) kitty nu fish cider-2;
|
inherit (channels.unstable) kitty nu fish cider-2 _1password-gui;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,9 @@
|
||||||
desktopItem = pkgs.makeDesktopItem {
|
desktopItem = pkgs.makeDesktopItem {
|
||||||
inherit name;
|
inherit name;
|
||||||
desktopName = "Open URL in a Browser";
|
desktopName = "Open URL in a Browser";
|
||||||
exec = "${bin}/bin/${name}";
|
comment = "Open the given URL in a browser-profile based on context";
|
||||||
|
mimeTypes = ["x-scheme-handler/http" "x-scheme-handler/https"];
|
||||||
|
exec = "${bin}/bin/${name} %u";
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
pkgs.symlinkJoin {
|
pkgs.symlinkJoin {
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ while [ "$parent" -ne 1 ]; do
|
||||||
parent=$(ps -o ppid= -p "$parent" | tail -n 1 | awk '{print $1}')
|
parent=$(ps -o ppid= -p "$parent" | tail -n 1 | awk '{print $1}')
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ $1 == "https://github.com/hausgold"* ]]; then
|
if [[ ${1:-} == "https://github.com/hausgold"* ]]; then
|
||||||
# Also use the `Work` profile for hausgold Github links
|
# Also use the `Work` profile for hausgold Github links
|
||||||
open_browser "Work" "$@"
|
open_browser "Work" "$@"
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,29 @@
|
||||||
{pkgs, ...}:
|
{
|
||||||
pkgs.writeTextFile rec {
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
lib._elements.writeNushellApplication pkgs {
|
||||||
name = "spawn-term";
|
name = "spawn-term";
|
||||||
destination = "/bin/${name}";
|
runtimeInputs = with pkgs; [kdotool];
|
||||||
executable = true;
|
|
||||||
|
|
||||||
text = ''
|
text = ''
|
||||||
#!/usr/bin/env nu
|
let focused_window = (kdotool getactivewindow)
|
||||||
|
|
||||||
let focused_window = (niri msg --json windows | from json | where { $in.is_focused == true } | first)
|
if (kdotool getwindowclassname $focused_window) == "kitty" {
|
||||||
|
let kitty_pid = (kdotool getwindowpid $focused_window | into int)
|
||||||
if ($focused_window | get app_id) == "kitty" {
|
if ($kitty_pid | is-empty) {
|
||||||
let child_pid = (pgrep -P $"($focused_window | get pid)" | tail -1)
|
|
||||||
if ($child_pid | is-empty) {
|
|
||||||
kitty
|
kitty
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
let path = ($"/proc/($child_pid)/cwd" | path expand)
|
let shell_pid = (ps | where ppid == $kitty_pid | where name != "kitten" | get pid | first)
|
||||||
|
if ($shell_pid | is-empty) {
|
||||||
|
kitty
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
let path = ($"/proc/($shell_pid)/cwd" | path expand)
|
||||||
kitty --directory $path
|
kitty --directory $path
|
||||||
} else {
|
} else {
|
||||||
kitty
|
kitty
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,10 @@ install host:
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
sudo nixos-install --flake "$(pwd)#{{host}}"
|
sudo nixos-install --flake "$(pwd)#{{host}}"
|
||||||
|
|
||||||
# Deploys the dotfile repository to a user's home dir.
|
# Deploys the dotfile repository to the host.
|
||||||
[no-cd]
|
[no-cd]
|
||||||
config host user:
|
config host user:
|
||||||
#!/usr/bin/env bash
|
cp -R $(pwd) "/mnt/nix/elements"
|
||||||
set -euxo pipefail
|
|
||||||
home=$(nix eval --extra-experimental-features "nix-command flakes" --impure --expr "(builtins.getFlake \"$(pwd)\").nixosConfigurations.{{host}}.config.users.users.{{user}}.home" | tail -n 1 | tr -d \")
|
|
||||||
cp -R $(pwd) "/mnt$home/.dotfiles"
|
|
||||||
|
|
||||||
# send-key:
|
# send-key:
|
||||||
# croc send ~/.ssh/id_key
|
# croc send ~/.ssh/id_key
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue