Add nix package installation

This commit is contained in:
aloslider committed 2026-07-04 20:57:58 +03:00
1 parent cfca5a109a
commit 60e546e2b8
4 files changed
+65 -9

No files matched your search

+12 -2
View File
@@ -4,24 +4,34 @@ packages:
- age - age
- base-devel - base-devel
- bat - bat
- btop
- bitwarden-cli - bitwarden-cli
- btop
- curl - curl
- dotnet-sdk - dotnet-sdk
- eza - eza
- fd
- ffmpeg
- fzf - fzf
- git - git
- imagemagick
- jq
- lazygit - lazygit
- npm - npm
- openssh - openssh
- poppler
- python-pip - python-pip
- resvg
- ripgrep - ripgrep
- tmux - tmux
- wget
- unzip - unzip
- wget
- yazi
- zoxide
- zsh - zsh
aur: aur:
- nixfmt - nixfmt
- prizrak-box-bin - prizrak-box-bin
- python-xmlformatter - python-xmlformatter
- tree-sitter-cli-github-bin - tree-sitter-cli-github-bin
go:
- github.com/davidbudnick/redis-tui
@@ -1,9 +1,14 @@
#!/bin/sh #!/bin/sh
set -euo pipefail set -euo pipefail
# NixOS
{{ if eq .chezmoi.osRelease.id "nixos" }}
exit 0
{{ end }}
echo "Installing native packages..." echo "Installing native packages..."
# 1. Arch-based # Arch-based
{{ if or (eq .chezmoi.osRelease.id "arch") (eq .chezmoi.osRelease.id "cachyos") }} {{ if or (eq .chezmoi.osRelease.id "arch") (eq .chezmoi.osRelease.id "cachyos") }}
sudo pacman -Sy --noconfirm sudo pacman -Sy --noconfirm
@@ -19,7 +24,6 @@ if [[ ${#pkgs[@]} -gt 0 ]]; then
sudo pacman -S --noconfirm --needed "${pkgs[@]}" sudo pacman -S --noconfirm --needed "${pkgs[@]}"
fi fi
# Install paru
if command -v paru >/dev/null 2>&1; then if command -v paru >/dev/null 2>&1; then
echo "Paru is already installed." echo "Paru is already installed."
else else
@@ -32,7 +36,6 @@ else
rm -rf "$build_dir" rm -rf "$build_dir"
fi fi
# Install AUR pkgs
aur_pkgs=() aur_pkgs=()
{{ range .packages.aur }} {{ range .packages.aur }}
if ! pacman -Q "{{ . }}" &>/dev/null; then if ! pacman -Q "{{ . }}" &>/dev/null; then
@@ -41,15 +44,35 @@ fi
{{ end }} {{ end }}
if [[ ${#aur_pkgs[@]} -gt 0 ]]; then if [[ ${#aur_pkgs[@]} -gt 0 ]]; then
echo "Installing AUR packages" echo "Installing AUR packages..."
paru -S --noconfirm --needed "${aur_pkgs[@]}" paru -S --noconfirm --needed "${aur_pkgs[@]}"
fi fi
{{ end }} {{ end }}
# 2. NixOS # Go packages
{{ if eq .chezmoi.osRelease.id "nixos" }} go_pkgs=()
exit 0 {{ range .packages.go }}
go_pkgs+=("{{ . }}")
{{ end }} {{ end }}
if ! command -v go >/dev/null 2>&1; then
echo "Go is not installed, skipping packages installation..."
else
for pkg in "${go_pkgs[@]}"; do
echo "Installing: $pkg"
go install "${pkg}@latest"
done
fi
# Nix packages
if ! command -v nix >/dev/null 2>&1; then
echo "Nix is not installed, skipping packages installation..."
else
FLAKE_DIR="$HOME/.config/nixpkgs"
if [ -d "$FLAKE_DIR" ] && [ -f "$FLAKE_DIR/flake.nix" ]; then
echo "Installing Nix packages..."
nix profile install "$FLAKE_DIR" || true
fi
fi
echo "Done" echo "Done"
+1
View File
@@ -0,0 +1 @@
experimental-features = nix-command flakes
+22
View File
@@ -0,0 +1,22 @@
{
description = "Nix packages";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
in {
packages.${system}.default = pkgs.buildEnv {
name = "user-packages";
paths = with pkgs; [
nixd
nixfmt
];
};
};
}