mirror of
https://github.com/anotherhadi/nixy.git
synced 2026-05-20 05:12:34 +02:00
Compare commits
6 Commits
325cacc86f
...
cd2896eb5d
| Author | SHA1 | Date | |
|---|---|---|---|
| cd2896eb5d | |||
| 35b79af191 | |||
| 3478a9a0a5 | |||
| f6d056deb3 | |||
| 795621ada6 | |||
| 31964cca35 |
+1
-7
@@ -23,16 +23,10 @@ Then import the home-manager module in your home configuration:
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ inputs, ... }: {
|
{ inputs, ... }: {
|
||||||
imports = [
|
imports = [ inputs.nixy.homeManagerModules.nvim ];
|
||||||
inputs.nixy.inputs.nvf.homeManagerModules.default
|
|
||||||
inputs.nixy.homeManagerModules.nvim
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
> [!NOTE]
|
|
||||||
> The `nvf` home-manager module is required. It is re-exported via `inputs.nixy.inputs.nvf` so you don't need to declare it separately in your own flake.
|
|
||||||
|
|
||||||
## What's included
|
## What's included
|
||||||
|
|
||||||
| File | Description |
|
| File | Description |
|
||||||
|
|||||||
@@ -87,6 +87,7 @@
|
|||||||
merge [
|
merge [
|
||||||
(import ./home/programs/nvf/flake.nix args)
|
(import ./home/programs/nvf/flake.nix args)
|
||||||
(import ./home/programs/group/flake.nix args)
|
(import ./home/programs/group/flake.nix args)
|
||||||
|
(import ./home/programs/nixy/flake.nix args)
|
||||||
{
|
{
|
||||||
nixosConfigurations = {
|
nixosConfigurations = {
|
||||||
h-laptop = import ./hosts/laptop/flake.nix args;
|
h-laptop = import ./hosts/laptop/flake.nix args;
|
||||||
|
|||||||
@@ -6,76 +6,26 @@
|
|||||||
#- - `nixy rebuild` - Rebuild the system.
|
#- - `nixy rebuild` - Rebuild the system.
|
||||||
#- - `nixy ...` - ... see the script for more commands.
|
#- - `nixy ...` - ... see the script for more commands.
|
||||||
{
|
{
|
||||||
pkgs,
|
|
||||||
config,
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: {
|
||||||
inherit (config.var) configDirectory;
|
options.programs.nixy = {
|
||||||
|
enable = lib.mkEnableOption "nixy";
|
||||||
|
configDirectory = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "$HOME/.config/nixos";
|
||||||
|
description = "Path to the NixOS configuration directory";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
nixy =
|
config = lib.mkIf config.programs.nixy.enable {
|
||||||
pkgs.writeShellScriptBin "nixy"
|
home.packages = [
|
||||||
# bash
|
(import ./package.nix {
|
||||||
''
|
inherit pkgs;
|
||||||
EXTRA_ARGS="''${@:2}"
|
inherit (config.programs.nixy) configDirectory;
|
||||||
|
})
|
||||||
function exec() {
|
];
|
||||||
$@
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function ui(){
|
|
||||||
DEFAULT_ICON=""
|
|
||||||
|
|
||||||
# "icon;name;command"[]
|
|
||||||
apps=(
|
|
||||||
";Rebuild;nixy rebuild"
|
|
||||||
";Test;nixy test"
|
|
||||||
";Update;nixy update"
|
|
||||||
";Collect Garbage;nixy gc"
|
|
||||||
";Clean Boot Menu;nixy cb"
|
|
||||||
";List generation;nixy listgen"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Apply default icons if empty:
|
|
||||||
for i in "''${!apps[@]}"; do
|
|
||||||
apps[i]=$(echo "''${apps[i]}" | sed 's/^;/'$DEFAULT_ICON';/')
|
|
||||||
done
|
|
||||||
|
|
||||||
fzf_result=$(printf "%s\n" "''${apps[@]}" | awk -F ';' '{print $1" "$2}' | fzf)
|
|
||||||
[[ -z $fzf_result ]] && exit 0
|
|
||||||
fzf_result=''${fzf_result/ /;}
|
|
||||||
line=$(printf "%s\n" "''${apps[@]}" | grep "$fzf_result")
|
|
||||||
command=$(echo "$line" | sed 's/^[^;]*;//;s/^[^;]*;//')
|
|
||||||
|
|
||||||
exec "$command"
|
|
||||||
exit $?
|
|
||||||
}
|
|
||||||
|
|
||||||
[[ $1 == "" ]] && ui
|
|
||||||
|
|
||||||
if [[ $1 == "rebuild" ]];then
|
|
||||||
cd ${configDirectory} && git add . && sudo nixos-rebuild switch --flake . $EXTRA_ARGS
|
|
||||||
elif [[ $1 == "test" ]];then
|
|
||||||
cd ${configDirectory} && git add . && sudo nixos-rebuild test --flake . $EXTRA_ARGS
|
|
||||||
elif [[ $1 == "update" ]];then
|
|
||||||
cd ${configDirectory} && nix flake update $EXTRA_ARGS
|
|
||||||
elif [[ $1 == "gc" ]];then
|
|
||||||
echo "Starting Nix garbage collection..."
|
|
||||||
cd ${configDirectory} && \
|
|
||||||
echo "Cleaning up system garbage..." && \
|
|
||||||
sudo nix-collect-garbage -d && \
|
|
||||||
echo "Cleaning up user garbage..." && \
|
|
||||||
nix-collect-garbage -d && \
|
|
||||||
echo "Collecting garbage from Nix store..." && \
|
|
||||||
nix-store --gc && \
|
|
||||||
echo "Optimizing Nix store..." && \
|
|
||||||
nix-store --optimise
|
|
||||||
echo "Nix garbage collection complete."
|
|
||||||
elif [[ $1 == "cb" ]];then
|
|
||||||
sudo /run/current-system/bin/switch-to-configuration boot
|
|
||||||
elif [[ $1 == "listgen" ]];then
|
|
||||||
sudo nix-env -p /nix/var/nix/profiles/system --list-generations
|
|
||||||
else
|
|
||||||
echo "Unknown argument"
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
in {home.packages = [nixy];}
|
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
system,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
|
packages.${system}.nixy = import ./package.nix {
|
||||||
|
inherit pkgs;
|
||||||
|
configDirectory = "$HOME/.config/nixos";
|
||||||
|
};
|
||||||
|
|
||||||
|
homeManagerModules.nixy = {imports = [./default.nix];};
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
configDirectory,
|
||||||
|
}:
|
||||||
|
pkgs.writeShellScriptBin "nixy"
|
||||||
|
# bash
|
||||||
|
''
|
||||||
|
EXTRA_ARGS="''${@:2}"
|
||||||
|
|
||||||
|
function exec() {
|
||||||
|
$@
|
||||||
|
}
|
||||||
|
|
||||||
|
function ui(){
|
||||||
|
DEFAULT_ICON=""
|
||||||
|
|
||||||
|
# "icon;name;command"[]
|
||||||
|
apps=(
|
||||||
|
";Rebuild;nixy rebuild"
|
||||||
|
";Test;nixy test"
|
||||||
|
";Update;nixy update"
|
||||||
|
";Collect Garbage;nixy gc"
|
||||||
|
";Clean Boot Menu;nixy cb"
|
||||||
|
";List generation;nixy listgen"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Apply default icons if empty:
|
||||||
|
for i in "''${!apps[@]}"; do
|
||||||
|
apps[i]=$(echo "''${apps[i]}" | sed 's/^;/'$DEFAULT_ICON';/')
|
||||||
|
done
|
||||||
|
|
||||||
|
fzf_result=$(printf "%s\n" "''${apps[@]}" | awk -F ';' '{print $1" "$2}' | fzf)
|
||||||
|
[[ -z $fzf_result ]] && exit 0
|
||||||
|
fzf_result=''${fzf_result/ /;}
|
||||||
|
line=$(printf "%s\n" "''${apps[@]}" | grep "$fzf_result")
|
||||||
|
command=$(echo "$line" | sed 's/^[^;]*;//;s/^[^;]*;//')
|
||||||
|
|
||||||
|
exec "$command"
|
||||||
|
exit $?
|
||||||
|
}
|
||||||
|
|
||||||
|
[[ $1 == "" ]] && ui
|
||||||
|
|
||||||
|
if [[ $1 == "rebuild" ]];then
|
||||||
|
cd ${configDirectory} && git add . && sudo nixos-rebuild switch --flake . $EXTRA_ARGS
|
||||||
|
elif [[ $1 == "test" ]];then
|
||||||
|
cd ${configDirectory} && git add . && sudo nixos-rebuild test --flake . $EXTRA_ARGS
|
||||||
|
elif [[ $1 == "update" ]];then
|
||||||
|
cd ${configDirectory} && nix flake update $EXTRA_ARGS
|
||||||
|
elif [[ $1 == "gc" ]];then
|
||||||
|
echo "Starting Nix garbage collection..."
|
||||||
|
cd ${configDirectory} && \
|
||||||
|
echo "Cleaning up system garbage..." && \
|
||||||
|
sudo nix-collect-garbage -d && \
|
||||||
|
echo "Cleaning up user garbage..." && \
|
||||||
|
nix-collect-garbage -d && \
|
||||||
|
echo "Collecting garbage from Nix store..." && \
|
||||||
|
nix-store --gc && \
|
||||||
|
echo "Optimizing Nix store..." && \
|
||||||
|
nix-store --optimise
|
||||||
|
echo "Nix garbage collection complete."
|
||||||
|
elif [[ $1 == "cb" ]];then
|
||||||
|
sudo /run/current-system/bin/switch-to-configuration boot
|
||||||
|
elif [[ $1 == "listgen" ]];then
|
||||||
|
sudo nix-env -p /nix/var/nix/profiles/system --list-generations
|
||||||
|
else
|
||||||
|
echo "Unknown argument"
|
||||||
|
fi
|
||||||
|
''
|
||||||
@@ -1,10 +1,5 @@
|
|||||||
{
|
{inputs, pkgs, ...}: {
|
||||||
inputs,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}: {
|
|
||||||
imports = [inputs.nvf.homeManagerModules.default];
|
imports = [inputs.nvf.homeManagerModules.default];
|
||||||
|
|
||||||
# Packages needed by snacks image preview
|
# Packages needed by snacks image preview
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
imagemagick
|
imagemagick
|
||||||
|
|||||||
@@ -28,5 +28,10 @@ in {
|
|||||||
program = "${nvimConfig.neovim}/bin/nvim";
|
program = "${nvimConfig.neovim}/bin/nvim";
|
||||||
};
|
};
|
||||||
|
|
||||||
homeManagerModules.nvim = {imports = [./default.nix];};
|
homeManagerModules.nvim = {
|
||||||
|
imports = [
|
||||||
|
inputs.nvf.homeManagerModules.default
|
||||||
|
./default.nix
|
||||||
|
];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,4 +47,9 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
programs.home-manager.enable = true;
|
programs.home-manager.enable = true;
|
||||||
|
|
||||||
|
programs.nixy = {
|
||||||
|
enable = true;
|
||||||
|
configDirectory = config.var.configDirectory;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,4 +23,9 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
programs.home-manager.enable = true;
|
programs.home-manager.enable = true;
|
||||||
|
|
||||||
|
programs.nixy = {
|
||||||
|
enable = true;
|
||||||
|
configDirectory = config.var.configDirectory;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,4 +40,9 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
programs.home-manager.enable = true;
|
programs.home-manager.enable = true;
|
||||||
|
|
||||||
|
programs.nixy = {
|
||||||
|
enable = true;
|
||||||
|
configDirectory = config.var.configDirectory;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user