Compare commits

..

15 Commits

Author SHA1 Message Date
434f14707c Enabled stylix to configure gtk 2026-06-02 12:48:09 +02:00
f94f6e63b1 Enable qt support in stylix, cleaned up comments and made stylix manage niri colors 2026-06-02 12:24:39 +02:00
ca285c92f7 Add noctalia module and removed waybar and other configurations no longer needed with noctalia 2026-06-02 12:22:05 +02:00
bcf0c17c51 Changed yakuake autostart to only start in KDE Plasma 2026-06-02 12:07:02 +02:00
5b9b48fede Configured git to be able to use lfs 2026-06-02 12:02:35 +02:00
fe2730b673 Added a symlink for cookiez assets flake input to /var/lib/assets 2026-06-02 12:01:54 +02:00
31b70d4221 Disabled specialisations as they arent needed for now 2026-06-02 11:59:45 +02:00
b9c0ab5f85 Fix: Added pinned kernel to flake outputs 2026-06-02 11:58:41 +02:00
09f39d1537 Removed awww as wallpapers will be handeled by noctalia 2026-06-02 11:57:56 +02:00
b696672f11 Pinned linux kernel version so I can rollback to specific versions in the past for things like bluetooth issues 2026-06-02 11:51:58 +02:00
1ed32e29b0 Added automatic nix store optimisation and garbage collection of versions older than 14 days 2026-05-31 20:11:19 +02:00
f04a72f19d Deleted hyprpaper and replaced it with awww. Also deleted self declared niri systemd services, as they arent needed with running commands at startup 2026-05-29 21:51:48 +02:00
3cf1f4f11f Merge pull request 'ncli-refactor' (#3) from ncli-refactor into main
Reviewed-on: #3
2026-05-29 20:49:44 +02:00
dbf7c1cd2e Refactored ncli to rebuild boot first, and then switch to new configuration after. 2026-05-29 11:13:35 +02:00
134fc441a5 - Simplified command cases by removing unnecessary semicolons.
- Improved error handling in rebuild.nix for clarity and consistency.
2026-05-29 09:29:31 +02:00
25 changed files with 632 additions and 921 deletions

60
flake.lock generated
View File

@ -45,6 +45,28 @@
"type": "github" "type": "github"
} }
}, },
"awww": {
"inputs": {
"flake-compat": "flake-compat_2",
"nixpkgs": [
"nixpkgs"
],
"rust-overlay": "rust-overlay_2"
},
"locked": {
"lastModified": 1779666993,
"narHash": "sha256-W0yA7Y37oj5BBzl4ojO8dtv9MuOvdrIZDxtRjs7kpdg=",
"ref": "refs/heads/main",
"rev": "9b7f47f7f394dce0a17a7b161e0d2fe391ce72b3",
"revCount": 1366,
"type": "git",
"url": "https://codeberg.org/LGFae/awww"
},
"original": {
"type": "git",
"url": "https://codeberg.org/LGFae/awww"
}
},
"base16": { "base16": {
"inputs": { "inputs": {
"fromYaml": "fromYaml" "fromYaml": "fromYaml"
@ -187,6 +209,22 @@
"type": "github" "type": "github"
} }
}, },
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1761588595,
"narHash": "sha256-XKUZz9zewJNUj46b4AJdiRZJAvSZ0Dqj2BNfXvFlJC4=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "f387cd2afec9419c8ee37694406ca490c3f34ee5",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": { "flake-parts": {
"inputs": { "inputs": {
"nixpkgs-lib": [ "nixpkgs-lib": [
@ -618,6 +656,7 @@
"inputs": { "inputs": {
"aagl": "aagl", "aagl": "aagl",
"alejandra": "alejandra", "alejandra": "alejandra",
"awww": "awww",
"cookiez-assets": "cookiez-assets", "cookiez-assets": "cookiez-assets",
"grub2-themes": "grub2-themes", "grub2-themes": "grub2-themes",
"home-manager": "home-manager", "home-manager": "home-manager",
@ -671,6 +710,27 @@
"type": "github" "type": "github"
} }
}, },
"rust-overlay_2": {
"inputs": {
"nixpkgs": [
"awww",
"nixpkgs"
]
},
"locked": {
"lastModified": 1764038373,
"narHash": "sha256-M6w2wNBRelcavoDAyFL2iO4NeWknD40ASkH1S3C0YGM=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "ab3536fe850211a96673c6ffb2cb88aab8071cc9",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"stylix": { "stylix": {
"inputs": { "inputs": {
"base16": "base16", "base16": "base16",

View File

@ -4,6 +4,9 @@
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
pinned-kernel.url = "github:NixOS/nixpkgs/3b5ec87c520b3f3f890c439da30b9fc3f7e173d3";
#To pin Kernel versin 7.0.10 because others have bluetooth issues
nix-index-database = { nix-index-database = {
url = "github:nix-community/nix-index-database"; url = "github:nix-community/nix-index-database";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
@ -32,8 +35,8 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
quickshell = { noctalia = {
url = "github:outfoxxed/quickshell"; url = "github:noctalia-dev/noctalia-shell/v5";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
@ -71,9 +74,11 @@
nixpkgs, nixpkgs,
alejandra, alejandra,
pam-fprint-grosshack, pam-fprint-grosshack,
pinned-kernel,
cookiez-assets, cookiez-assets,
home-manager, home-manager,
plasma-manager, plasma-manager,
noctalia,
nixos-hardware, nixos-hardware,
aagl, aagl,
stylix, stylix,

View File

@ -15,7 +15,9 @@
system, system,
pam-fprint-grosshack-pkg, pam-fprint-grosshack-pkg,
... ...
}: { }: let
kernel-pinned = import inputs.pinned-kernel {inherit system;};
in {
#Assign Swap to the PC #Assign Swap to the PC
swapDevices = [ swapDevices = [
{ {
@ -25,7 +27,15 @@
} }
]; ];
nix = { nix = {
settings.nix-path = config.nix.nixPath; gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 14d";
};
settings = {
auto-optimise-store = true;
nix-path = config.nix.nixPath;
};
nixPath = ["nixpkgs=${inputs.nixpkgs}"]; nixPath = ["nixpkgs=${inputs.nixpkgs}"];
}; };
@ -46,7 +56,7 @@
# Bootloader. # Bootloader.
boot = { boot = {
kernelPackages = pkgs.linuxPackages_latest; kernelPackages = kernel-pinned.linuxPackages_latest;
kernelParams = ["quiet" "splash"]; kernelParams = ["quiet" "splash"];
initrd = { initrd = {
systemd.enable = true; #For swap to automatically work systemd.enable = true; #For swap to automatically work
@ -186,9 +196,14 @@
openssh.enable = true; openssh.enable = true;
}; };
systemd.services.fprintd = { systemd = {
wantedBy = ["multi-user.target"]; tmpfiles.rules = [
serviceConfig.Type = "simple"; "L+ /var/lib/assets - - - - ${inputs.cookiez-assets}"
];
services.fprintd = {
wantedBy = ["multi-user.target"];
serviceConfig.Type = "simple";
};
}; };
fonts = { fonts = {
@ -304,7 +319,7 @@
users.users.${username} = { users.users.${username} = {
isNormalUser = true; isNormalUser = true;
description = "Cookiez"; description = "Cookiez";
extraGroups = ["networkmanager" "wheel" "docker" "gamemode"]; extraGroups = ["networkmanager" "wheel" "docker" "gamemode" "dialout" "tty"];
packages = with pkgs; [ packages = with pkgs; [
#User Packages Here #User Packages Here
]; ];
@ -375,9 +390,8 @@
max-substitution-jobs = 32; max-substitution-jobs = 32;
http-connections = 50; http-connections = 50;
#Both needed for sleepy-launcher to work extra-substituters = ["https://ezkea.cachix.org" "https://noctalia.cachix.org" "https://nix-community.cachix.org"];
extra-substituters = ["https://ezkea.cachix.org" "https://nix-community.cachix.org"]; extra-trusted-public-keys = ["ezkea.cachix.org-1:ioBmUbJTZIKsHmWWXPe1FSFbeVe+afhfgqgTSNd34eI=" "noctalia.cachix.org-1:pCOR47nnMEo5thcxNDtzWpOxNFQsBRglJzxWPp3dkU4=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="];
extra-trusted-public-keys = ["ezkea.cachix.org-1:ioBmUbJTZIKsHmWWXPe1FSFbeVe+afhfgqgTSNd34eI=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="];
}; };
# Allow unfree packages # Allow unfree packages

View File

@ -7,40 +7,40 @@
../niri ../niri
]; ];
specialisation = { #specialisation = {
"plasma" = { # "plasma" = {
inheritParentConfig = false; # inheritParentConfig = false;
configuration = { # configuration = {
imports = [ # imports = [
../plasma # ../plasma
./configuration.nix # ./configuration.nix
]; # ];
#
# environment.etc."nixos-tags".text = "plasma";
# };
# };
environment.etc."nixos-tags".text = "plasma"; # "minimal" = {
}; # inheritParentConfig = false;
}; # configuration = {
# imports = [
# ./minimal.nix
# ];
#
# environment.etc."nixos-tags".text = "minimal";
# };
# };
# "minimal" = { # "niri" = {
# inheritParentConfig = false; # inheritParentConfig = false;
# configuration = { # configuration = {
# imports = [ # imports = [
# ./minimal.nix # ../niri
# ]; # ./configuration.nix
# # ];
# environment.etc."nixos-tags".text = "minimal"; #
# }; # environment.etc."nixos-tags".text = "niri";
# }; # };
# };
"niri" = { #};
inheritParentConfig = false;
configuration = {
imports = [
../niri
./configuration.nix
];
environment.etc."nixos-tags".text = "niri";
};
};
};
} }

View File

@ -74,6 +74,7 @@
git = { git = {
enable = true; enable = true;
lfs.enable = true;
settings = { settings = {
user = { user = {
name = "Cookiez"; name = "Cookiez";

View File

@ -1,26 +0,0 @@
{
pkgs,
inputs,
username,
project,
...
}: {
imports = [
];
services = {
hyprpaper = {
enable = false;
settings = {
wallpaper = [
{
monitor = "eDP-1";
path = "${inputs.cookiez-assets}/wallpapers/pixel-desert.png";
fit_mode = "cover"; # optional, defaults to cover
}
];
};
};
};
}

View File

@ -18,33 +18,35 @@
# --- Help text --- # --- Help text ---
print_help = '' print_help = ''
echo "NixOS CLI Utility -- version 2.1.3" print_help() {
echo "" echo "NixOS CLI Utility -- version 2.1.3"
echo "Usage: ncli [command]" echo ""
echo "" echo "Usage: ncli [command]"
echo "System Commands:" echo ""
echo " rebuild - Rebuild the NixOS system configuration." echo "System Commands:"
echo " update - Update the flake and rebuild the system." echo " rebuild - Rebuild the NixOS system configuration."
echo "" echo " update - Update the flake and rebuild the system."
echo "Maintenance Commands:" echo ""
echo " cleanup - Clean up old system generations. Can specify a number to keep." echo "Maintenance Commands:"
echo " diag - Create a system diagnostic report (saves to ~/diag.txt)." echo " cleanup - Clean up old system generations. Can specify a number to keep."
echo " list-gens - List user and system generations." echo " diag - Create a system diagnostic report (saves to ~/diag.txt)."
echo " trim - Trim filesystems to improve SSD performance." echo " list-gens - List user and system generations."
echo "" echo " trim - Trim filesystems to improve SSD performance."
echo "Git Commands:" echo ""
echo " commit [msg] - Add all changes and commit with message." echo "Git Commands:"
echo " push - Push changes to origin." echo " commit [msg] - Add all changes and commit with message."
echo " pull - Pull latest changes from origin." echo " push - Push changes to origin."
echo " status - Show git status." echo " pull - Pull latest changes from origin."
echo "" echo " status - Show git status."
echo "Development Commands:" echo ""
echo " dev - Initialize a Nix development environment (flake.nix + direnv)." echo "Development Commands:"
echo " dev track - Remove assume-unchanged flag from flake files." echo " dev - Initialize a Nix development environment (flake.nix + direnv)."
echo " dev untrack - Mark flake files as assume-unchanged in a directory." echo " dev track - Remove assume-unchanged flag from flake files."
echo "" echo " dev untrack - Mark flake files as assume-unchanged in a directory."
echo " help - Show this help message." echo ""
echo "" echo " help - Show this help message."
echo ""
}
''; '';
in in
pkgs.writeShellScriptBin "ncli" '' pkgs.writeShellScriptBin "ncli" ''
@ -70,6 +72,7 @@ in
${lib.print_success} ${lib.print_success}
${lib.print_error} ${lib.print_error}
${lib.print_info} ${lib.print_info}
${print_help}
# --- Main Logic --- # --- Main Logic ---
if [ "$#" -eq 0 ]; then if [ "$#" -eq 0 ]; then
@ -122,7 +125,7 @@ in
${dev.dev_case} ${dev.dev_case}
;; ;;
help) help)
${print_help} print_help
;; ;;
*) *)
echo "Error: Invalid command '$1'" >&2 echo "Error: Invalid command '$1'" >&2

View File

@ -1,367 +1,364 @@
# ncli/commands/dev.nix — dev init / track / untrack # ncli/commands/dev.nix — dev init / track / untrack
lib: lib: {
{
dev_case = '' dev_case = ''
# Only flake files need assume-unchanged (Nix requires them in the index). # Only flake files need assume-unchanged (Nix requires them in the index).
# .envrc and .direnv are handled via .git/info/exclude instead. # .envrc and .direnv are handled via .git/info/exclude instead.
DEV_FILES=(flake.nix flake.lock) DEV_FILES=(flake.nix flake.lock)
DIRENV_LOCAL_FILES=(.envrc .direnv) DIRENV_LOCAL_FILES=(.envrc .direnv)
_dev_resolve_dir() { _dev_resolve_dir() {
read -rp " Enter target directory [./]: " TARGET_DIR read -rp " Enter target directory [./]: " TARGET_DIR
TARGET_DIR="''${TARGET_DIR:-./}" TARGET_DIR="''${TARGET_DIR:-./}"
if [[ ! -d "$TARGET_DIR" ]]; then if [[ ! -d "$TARGET_DIR" ]]; then
print_error "Directory '$TARGET_DIR' does not exist." print_error "Directory '$TARGET_DIR' does not exist."
exit 1
fi
TARGET_ABS="$(cd "$TARGET_DIR" && pwd)"
if ! git -C "$TARGET_ABS" rev-parse --git-dir > /dev/null 2>&1; then
print_error "No Git repository found at '$TARGET_ABS'."
exit 1
fi
}
_add_local_excludes() {
local repo_abs="$1"
local git_dir exclude_file
git_dir="$(git -C "$repo_abs" rev-parse --git-dir)"
exclude_file="$git_dir/info/exclude"
mkdir -p "$(dirname "$exclude_file")"
touch "$exclude_file"
for entry in "''${DIRENV_LOCAL_FILES[@]}"; do
if ! grep -qxF "$entry" "$exclude_file" 2>/dev/null; then
echo "$entry" >> "$exclude_file"
print_success "$entry ignored via .git/info/exclude (local only)"
else
print_info "$entry already in .git/info/exclude, skipping."
fi
done
}
_remove_local_excludes() {
local repo_abs="$1"
local git_dir exclude_file tmp_file
git_dir="$(git -C "$repo_abs" rev-parse --git-dir)"
exclude_file="$git_dir/info/exclude"
[[ -f "$exclude_file" ]] || return 0
tmp_file="$(mktemp)"
cp "$exclude_file" "$tmp_file"
for entry in "''${DIRENV_LOCAL_FILES[@]}"; do
if grep -qxF "$entry" "$tmp_file" 2>/dev/null; then
grep -vxF "$entry" "$tmp_file" > "''${tmp_file}.new" || true
mv "''${tmp_file}.new" "$tmp_file"
print_success "$entry removed from .git/info/exclude"
else
print_info "$entry not present in .git/info/exclude, skipping."
fi
done
mv "$tmp_file" "$exclude_file"
}
case "''${2:-init}" in
untrack)
echo ""
echo -e "''${BLUE}--- Dev: Track Files (assume-unchanged) ---''${NOCOLOR}"
echo ""
_dev_resolve_dir
acted=false
for f in "''${DEV_FILES[@]}"; do
full="$TARGET_ABS/$f"
if [[ ! -f "$full" ]]; then
print_info "$f not found in $TARGET_ABS skipping."
continue
fi
if ! git -C "$TARGET_ABS" ls-files --error-unmatch "$f" > /dev/null 2>&1; then
git -C "$TARGET_ABS" add --intent-to-add "$f"
fi
git -C "$TARGET_ABS" update-index --assume-unchanged "$f"
print_success "$f untracked (assume-unchanged)"
acted=true
done
_add_local_excludes "$TARGET_ABS"
if ! $acted; then
print_info "No dev files found in '$TARGET_ABS' to track."
fi
;;
track)
echo ""
echo -e "''${BLUE}--- Dev: Untrack Files (remove assume-unchanged) ---''${NOCOLOR}"
echo ""
_dev_resolve_dir
acted=false
for f in "''${DEV_FILES[@]}"; do
if git -C "$TARGET_ABS" ls-files -v "$f" 2>/dev/null | grep -q "^h "; then
git -C "$TARGET_ABS" update-index --no-assume-unchanged "$f"
print_success "$f tracked (assume-unchanged removed)"
acted=true
else
print_info "$f is not marked assume-unchanged skipping."
fi
done
_remove_local_excludes "$TARGET_ABS"
if ! $acted; then
print_info "No files in '$TARGET_ABS' had the assume-unchanged bit set."
fi
;;
init|*)
SOURCE_FLAKE="$HOME/${lib.project}/other/dev-template.nix"
if [[ ! -f "$SOURCE_FLAKE" ]]; then
print_error "Source flake template not found: $SOURCE_FLAKE"
echo "Please ensure dev-template.nix exists in $HOME/${lib.project}/other/"
exit 1 exit 1
fi fi
TARGET_ABS="$(cd "$TARGET_DIR" && pwd)"
print_header if ! git -C "$TARGET_ABS" rev-parse --git-dir > /dev/null 2>&1; then
print_error "No Git repository found at '$TARGET_ABS'."
# ---- Step 1: Target Directory ----
echo -e "''${YELLOW}Step 1/5: Target Directory''${NOCOLOR}"
echo ""
read -p " Enter target directory [./]: " TARGET_DIR
if [[ -z "$TARGET_DIR" ]]; then
TARGET_DIR="./"
fi
if [[ ! -d "$TARGET_DIR" ]]; then
print_error "Directory '$TARGET_DIR' does not exist. Exiting."
exit 1 exit 1
fi fi
}
print_success "Target directory: $TARGET_DIR" _add_local_excludes() {
echo "" local repo_abs="$1"
local git_dir exclude_file
git_dir="$(git -C "$repo_abs" rev-parse --git-dir)"
exclude_file="$git_dir/info/exclude"
mkdir -p "$(dirname "$exclude_file")"
touch "$exclude_file"
# ---- Check for existing flake ---- for entry in "''${DIRENV_LOCAL_FILES[@]}"; do
if [[ -f "$TARGET_DIR/flake.nix" ]]; then if ! grep -qxF "$entry" "$exclude_file" 2>/dev/null; then
echo "" echo "$entry" >> "$exclude_file"
print_error "A flake.nix already exists in '$TARGET_DIR'!" print_success "$entry ignored via .git/info/exclude (local only)"
echo ""
read -p " Would you like to just place the .envrc instead? [y/N]: " ENVRC_ONLY
ENVRC_ONLY="''${ENVRC_ONLY:-N}"
if [[ "$ENVRC_ONLY" =~ ^[Yy]$ ]]; then
TARGET_ABS="$(cd "$TARGET_DIR" && pwd)"
echo ""
print_info "Placing .envrc only..."
if ! grep -qxF "use flake" "$TARGET_ABS/.envrc" 2>/dev/null; then
echo "use flake" >> "$TARGET_ABS/.envrc"
print_success ".envrc created at $TARGET_ABS/"
else
print_info ".envrc already contains 'use flake', nothing to do."
fi
echo ""
print_info "Next steps:"
echo " cd $TARGET_DIR"
echo " direnv allow"
echo ""
exit 0
else else
print_info "Aborting. No files were changed." print_info "$entry already in .git/info/exclude, skipping."
exit 1
fi fi
fi done
}
# ---- Step 2: Project Name ---- _remove_local_excludes() {
echo -e "''${YELLOW}Step 2/5: Project Name''${NOCOLOR}" local repo_abs="$1"
echo "" local git_dir exclude_file tmp_file
read -p " Enter development environment name [devShell]: " PROJECT_NAME git_dir="$(git -C "$repo_abs" rev-parse --git-dir)"
exclude_file="$git_dir/info/exclude"
if [[ -z "$PROJECT_NAME" ]]; then [[ -f "$exclude_file" ]] || return 0
PROJECT_NAME="devShell"
fi
print_success "Project name: $PROJECT_NAME" tmp_file="$(mktemp)"
echo "" cp "$exclude_file" "$tmp_file"
# ---- Step 3: Select template ---- for entry in "''${DIRENV_LOCAL_FILES[@]}"; do
echo -e "''${YELLOW}Step 3/5: Select Template''${NOCOLOR}" if grep -qxF "$entry" "$tmp_file" 2>/dev/null; then
echo "" grep -vxF "$entry" "$tmp_file" > "''${tmp_file}.new" || true
echo " 1) Empty - Basic shell, add packages yourself" mv "''${tmp_file}.new" "$tmp_file"
echo " 2) Python - Python 3, pip, venv setup" print_success "$entry removed from .git/info/exclude"
echo " 3) Node.js - Node.js, npm" else
echo " 4) Rust - Rustc, cargo, rust-analyzer" print_info "$entry not present in .git/info/exclude, skipping."
echo " 5) Go - Go, gopls, golangci-lint" fi
echo " 6) C/C++ - GCC, CMake, GDB, pkg-config" done
echo " 7) Java - JDK 21, Maven"
echo ""
read -p " Select template [1-7] (default: 1): " TEMPLATE_CHOICE mv "$tmp_file" "$exclude_file"
}
case "$TEMPLATE_CHOICE" in case "''${2:-init}" in
2)
TEMPLATE="python3"
PACKAGES="python3 python3Packages.pip python3Packages.virtualenv"
BUILD_INPUTS=""
SHELL_HOOK_EXTRA="
if [ ! -d .venv ]; then
echo 'Creating Python virtual environment...'
python3 -m venv .venv
fi
source .venv/bin/activate
echo 'Python venv activated.'
"
;;
3)
TEMPLATE="node"
PACKAGES="nodejs_22"
BUILD_INPUTS=""
SHELL_HOOK_EXTRA='echo "Node.js $(node --version) ready."'
;;
4)
TEMPLATE="rust"
PACKAGES="rustc cargo rust-analyzer"
BUILD_INPUTS="openssl pkg-config"
SHELL_HOOK_EXTRA='echo "Rust $(rustc --version) ready."'
;;
5)
TEMPLATE="go"
PACKAGES="go gopls golangci-lint"
BUILD_INPUTS=""
SHELL_HOOK_EXTRA='
export GOPATH="$PWD/.gopath"
export PATH="$GOPATH/bin:$PATH"
mkdir -p "$GOPATH"
echo "Go $(go version) ready. GOPATH: $GOPATH"
'
;;
6)
TEMPLATE="cpp"
PACKAGES="gcc gdb cmake gnumake"
BUILD_INPUTS="pkg-config"
SHELL_HOOK_EXTRA='echo "GCC $(gcc --version | head -1) ready."'
;;
7)
TEMPLATE="java"
PACKAGES="jdk21 maven"
BUILD_INPUTS=""
SHELL_HOOK_EXTRA='echo "Java $(java --version | head -1) ready."'
;;
*)
TEMPLATE="empty"
PACKAGES=""
BUILD_INPUTS=""
SHELL_HOOK_EXTRA=""
;;
esac
print_success "Selected template: $TEMPLATE" untrack)
echo ""
# ---- Step 4: Copy and modify flake ----
echo -e "''${YELLOW}Step 4/5: Generating flake.nix''${NOCOLOR}"
echo ""
cp "$SOURCE_FLAKE" "$TARGET_DIR/flake.nix"
print_success "Copied flake.nix to $TARGET_DIR/"
sed -i "s|name = \"replaceNameHere\";|name = \"''${PROJECT_NAME}\";|" "$TARGET_DIR/flake.nix"
print_success "Set project name: $PROJECT_NAME"
if [[ -n "$PACKAGES" ]]; then
sed -i "s|# replacePackagesHere|$PACKAGES|" "$TARGET_DIR/flake.nix"
print_success "Added packages: $PACKAGES"
fi
if [[ -n "$BUILD_INPUTS" ]]; then
BUILD_INPUTS_LINE="buildInputs = with pkgs; [ $BUILD_INPUTS ];"
sed -i "s|# replaceBuildInputsHere|$BUILD_INPUTS_LINE|" "$TARGET_DIR/flake.nix"
print_success "Added build inputs: $BUILD_INPUTS"
fi
if [[ -n "$SHELL_HOOK_EXTRA" ]]; then
awk -v hook="$SHELL_HOOK_EXTRA" '/# replaceShellHookHere/ { print hook; next } { print }' \
"$TARGET_DIR/flake.nix" > "$TARGET_DIR/flake.nix.tmp" \
&& mv "$TARGET_DIR/flake.nix.tmp" "$TARGET_DIR/flake.nix"
print_success "Added template-specific shell hook"
fi
# ---- Step 5: Git Integration & .envrc ----
echo -e "''${YELLOW}Step 5/5: Git Integration''${NOCOLOR}"
echo ""
TARGET_ABS="$(cd "$TARGET_DIR" && pwd)"
echo "Creating .envrc for direnv to automatically work!"
if ! grep -qxF "use flake" "$TARGET_ABS/.envrc" 2>/dev/null; then
echo "use flake" >> "$TARGET_ABS/.envrc"
print_success ".envrc created at $TARGET_ABS/"
else
print_info ".envrc already contains 'use flake', skipping."
fi
if git -C "$TARGET_ABS" rev-parse --git-dir > /dev/null 2>&1; then
echo " A Git repository was detected at:"
echo " $(git -C "$TARGET_ABS" rev-parse --show-toplevel)"
echo "" echo ""
echo -e "''${BLUE}--- Dev: Track Files (assume-unchanged) ---''${NOCOLOR}"
echo ""
_dev_resolve_dir
acted=false
for f in "''${DEV_FILES[@]}"; do
full="$TARGET_ABS/$f"
if [[ ! -f "$full" ]]; then
print_info "$f not found in $TARGET_ABS skipping."
continue
fi
if ! git -C "$TARGET_ABS" ls-files --error-unmatch "$f" > /dev/null 2>&1; then
git -C "$TARGET_ABS" add --intent-to-add "$f"
fi
git -C "$TARGET_ABS" update-index --assume-unchanged "$f"
print_success "$f untracked (assume-unchanged)"
acted=true
done
_add_local_excludes "$TARGET_ABS" _add_local_excludes "$TARGET_ABS"
if ! $acted; then
print_info "No dev files found in '$TARGET_ABS' to track."
fi
;;
track)
echo ""
echo -e "''${BLUE}--- Dev: Untrack Files (remove assume-unchanged) ---''${NOCOLOR}"
echo ""
_dev_resolve_dir
acted=false
for f in "''${DEV_FILES[@]}"; do
if git -C "$TARGET_ABS" ls-files -v "$f" 2>/dev/null | grep -q "^h "; then
git -C "$TARGET_ABS" update-index --no-assume-unchanged "$f"
print_success "$f tracked (assume-unchanged removed)"
acted=true
else
print_info "$f is not marked assume-unchanged skipping."
fi
done
_remove_local_excludes "$TARGET_ABS"
if ! $acted; then
print_info "No files in '$TARGET_ABS' had the assume-unchanged bit set."
fi
;;
init|*)
SOURCE_FLAKE="$HOME/${lib.project}/other/dev-template.nix"
if [[ ! -f "$SOURCE_FLAKE" ]]; then
print_error "Source flake template not found: $SOURCE_FLAKE"
echo "Please ensure dev-template.nix exists in $HOME/${lib.project}/other/"
exit 1
fi
print_header
# ---- Step 1: Target Directory ----
echo -e "''${YELLOW}Step 1/5: Target Directory''${NOCOLOR}"
echo ""
read -p " Enter target directory [./]: " TARGET_DIR
if [[ -z "$TARGET_DIR" ]]; then
TARGET_DIR="./"
fi
if [[ ! -d "$TARGET_DIR" ]]; then
print_error "Directory '$TARGET_DIR' does not exist. Exiting."
exit 1
fi
print_success "Target directory: $TARGET_DIR"
echo "" echo ""
echo " Nix flakes require flake.nix (and flake.lock) to be Git-tracked." # ---- Check for existing flake ----
echo " This script can stage them as 'assume-unchanged' so Nix sees them," if [[ -f "$TARGET_DIR/flake.nix" ]]; then
echo " but they will NEVER be committed or show up in git status."
echo ""
read -p " Set up flake files as tracked-but-invisible to Git? [y/N]: " GIT_CHOICE
GIT_CHOICE="''${GIT_CHOICE:-N}"
if [[ "$GIT_CHOICE" =~ ^[Yy]$ ]]; then
cat > "$TARGET_ABS/flake.lock" << 'FLAKE_LOCK_EOF'
{
"nodes": {
"root": {}
},
"root": "root",
"version": 7
}
FLAKE_LOCK_EOF
print_success "flake.lock ready (Nix will populate it on first run if empty)"
git -C "$TARGET_ABS" add --intent-to-add flake.nix flake.lock
git -C "$TARGET_ABS" update-index --assume-unchanged flake.nix flake.lock
print_success "flake.nix + flake.lock tracked (assume-unchanged)"
else
print_info "Skipped. You can do this manually later:"
echo "" echo ""
echo " git -C \"$TARGET_ABS\" add --intent-to-add flake.nix flake.lock" print_error "A flake.nix already exists in '$TARGET_DIR'!"
echo " git -C \"$TARGET_ABS\" update-index --assume-unchanged flake.nix flake.lock" echo ""
read -p " Would you like to just place the .envrc instead? [y/N]: " ENVRC_ONLY
ENVRC_ONLY="''${ENVRC_ONLY:-N}"
if [[ "$ENVRC_ONLY" =~ ^[Yy]$ ]]; then
TARGET_ABS="$(cd "$TARGET_DIR" && pwd)"
echo ""
print_info "Placing .envrc only..."
if ! grep -qxF "use flake" "$TARGET_ABS/.envrc" 2>/dev/null; then
echo "use flake" >> "$TARGET_ABS/.envrc"
print_success ".envrc created at $TARGET_ABS/"
else
print_info ".envrc already contains 'use flake', nothing to do."
fi
echo ""
print_info "Next steps:"
echo " cd $TARGET_DIR"
echo " direnv allow"
echo ""
exit 0
else
print_info "Aborting. No files were changed."
exit 1
fi
fi
# ---- Step 2: Project Name ----
echo -e "''${YELLOW}Step 2/5: Project Name''${NOCOLOR}"
echo ""
read -p " Enter development environment name [devShell]: " PROJECT_NAME
if [[ -z "$PROJECT_NAME" ]]; then
PROJECT_NAME="devShell"
fi
print_success "Project name: $PROJECT_NAME"
echo ""
# ---- Step 3: Select template ----
echo -e "''${YELLOW}Step 3/5: Select Template''${NOCOLOR}"
echo ""
echo " 1) Empty - Basic shell, add packages yourself"
echo " 2) Python - Python 3, pip, venv setup"
echo " 3) Node.js - Node.js, npm"
echo " 4) Rust - Rustc, cargo, rust-analyzer"
echo " 5) Go - Go, gopls, golangci-lint"
echo " 6) C/C++ - GCC, CMake, GDB, pkg-config"
echo " 7) Java - JDK 21, Maven"
echo ""
read -p " Select template [1-7] (default: 1): " TEMPLATE_CHOICE
case "$TEMPLATE_CHOICE" in
2)
TEMPLATE="python3"
PACKAGES="python3 python3Packages.pip python3Packages.virtualenv"
BUILD_INPUTS=""
SHELL_HOOK_EXTRA="
if [ ! -d .venv ]; then
echo 'Creating Python virtual environment...'
python3 -m venv .venv
fi
source .venv/bin/activate
echo 'Python venv activated.'
"
;;
3)
TEMPLATE="node"
PACKAGES="nodejs_22"
BUILD_INPUTS=""
SHELL_HOOK_EXTRA='echo "Node.js $(node --version) ready."'
;;
4)
TEMPLATE="rust"
PACKAGES="rustc cargo rust-analyzer"
BUILD_INPUTS="openssl pkg-config"
SHELL_HOOK_EXTRA='echo "Rust $(rustc --version) ready."'
;;
5)
TEMPLATE="go"
PACKAGES="go gopls golangci-lint"
BUILD_INPUTS=""
SHELL_HOOK_EXTRA='
export GOPATH="$PWD/.gopath"
export PATH="$GOPATH/bin:$PATH"
mkdir -p "$GOPATH"
echo "Go $(go version) ready. GOPATH: $GOPATH"
'
;;
6)
TEMPLATE="cpp"
PACKAGES="gcc gdb cmake gnumake"
BUILD_INPUTS="pkg-config"
SHELL_HOOK_EXTRA='echo "GCC $(gcc --version | head -1) ready."'
;;
7)
TEMPLATE="java"
PACKAGES="jdk21 maven"
BUILD_INPUTS=""
SHELL_HOOK_EXTRA='echo "Java $(java --version | head -1) ready."'
;;
*)
TEMPLATE="empty"
PACKAGES=""
BUILD_INPUTS=""
SHELL_HOOK_EXTRA=""
;;
esac
print_success "Selected template: $TEMPLATE"
echo ""
# ---- Step 4: Copy and modify flake ----
echo -e "''${YELLOW}Step 4/5: Generating flake.nix''${NOCOLOR}"
echo ""
cp "$SOURCE_FLAKE" "$TARGET_DIR/flake.nix"
print_success "Copied flake.nix to $TARGET_DIR/"
sed -i "s|name = \"replaceNameHere\";|name = \"''${PROJECT_NAME}\";|" "$TARGET_DIR/flake.nix"
print_success "Set project name: $PROJECT_NAME"
if [[ -n "$PACKAGES" ]]; then
sed -i "s|# replacePackagesHere|$PACKAGES|" "$TARGET_DIR/flake.nix"
print_success "Added packages: $PACKAGES"
fi
if [[ -n "$BUILD_INPUTS" ]]; then
BUILD_INPUTS_LINE="buildInputs = with pkgs; [ $BUILD_INPUTS ];"
sed -i "s|# replaceBuildInputsHere|$BUILD_INPUTS_LINE|" "$TARGET_DIR/flake.nix"
print_success "Added build inputs: $BUILD_INPUTS"
fi
if [[ -n "$SHELL_HOOK_EXTRA" ]]; then
awk -v hook="$SHELL_HOOK_EXTRA" '/# replaceShellHookHere/ { print hook; next } { print }' \
"$TARGET_DIR/flake.nix" > "$TARGET_DIR/flake.nix.tmp" \
&& mv "$TARGET_DIR/flake.nix.tmp" "$TARGET_DIR/flake.nix"
print_success "Added template-specific shell hook"
fi
# ---- Step 5: Git Integration & .envrc ----
echo -e "''${YELLOW}Step 5/5: Git Integration''${NOCOLOR}"
echo ""
TARGET_ABS="$(cd "$TARGET_DIR" && pwd)"
echo "Creating .envrc for direnv to automatically work!"
if ! grep -qxF "use flake" "$TARGET_ABS/.envrc" 2>/dev/null; then
echo "use flake" >> "$TARGET_ABS/.envrc"
print_success ".envrc created at $TARGET_ABS/"
else
print_info ".envrc already contains 'use flake', skipping."
fi
if git -C "$TARGET_ABS" rev-parse --git-dir > /dev/null 2>&1; then
echo " A Git repository was detected at:"
echo " $(git -C "$TARGET_ABS" rev-parse --show-toplevel)"
echo ""
_add_local_excludes "$TARGET_ABS"
echo ""
echo " Nix flakes require flake.nix (and flake.lock) to be Git-tracked."
echo " This script can stage them as 'assume-unchanged' so Nix sees them,"
echo " but they will NEVER be committed or show up in git status."
echo ""
read -p " Set up flake files as tracked-but-invisible to Git? [y/N]: " GIT_CHOICE
GIT_CHOICE="''${GIT_CHOICE:-N}"
if [[ "$GIT_CHOICE" =~ ^[Yy]$ ]]; then
cat > "$TARGET_ABS/flake.lock" << 'FLAKE_LOCK_EOF'
{
"nodes": {
"root": {}
},
"root": "root",
"version": 7
}
FLAKE_LOCK_EOF
print_success "flake.lock ready (Nix will populate it on first run if empty)"
git -C "$TARGET_ABS" add --intent-to-add flake.nix flake.lock
git -C "$TARGET_ABS" update-index --assume-unchanged flake.nix flake.lock
print_success "flake.nix + flake.lock tracked (assume-unchanged)"
else
print_info "Skipped. You can do this manually later:"
echo ""
echo " git -C \"$TARGET_ABS\" add --intent-to-add flake.nix flake.lock"
echo " git -C \"$TARGET_ABS\" update-index --assume-unchanged flake.nix flake.lock"
echo ""
fi
else
print_info "No Git repository detected skipping Git integration."
echo "" echo ""
fi fi
else
print_info "No Git repository detected skipping Git integration." # ---- Done ----
echo -e "''${GREEN}==============================================''${NOCOLOR}"
echo -e "''${GREEN} Done! Your flake is ready at:''${NOCOLOR}"
echo -e "''${GREEN} $TARGET_DIR/flake.nix''${NOCOLOR}"
echo -e "''${GREEN}==============================================''${NOCOLOR}"
echo "" echo ""
fi print_info "Next steps:"
echo " cd $TARGET_DIR"
echo " direnv allow # Trust the .envrc so direnv auto-activates"
echo " nix develop # Or just: cd out and back in"
echo ""
;;
# ---- Done ---- esac
echo -e "''${GREEN}==============================================''${NOCOLOR}"
echo -e "''${GREEN} Done! Your flake is ready at:''${NOCOLOR}"
echo -e "''${GREEN} $TARGET_DIR/flake.nix''${NOCOLOR}"
echo -e "''${GREEN}==============================================''${NOCOLOR}"
echo ""
print_info "Next steps:"
echo " cd $TARGET_DIR"
echo " direnv allow # Trust the .envrc so direnv auto-activates"
echo " nix develop # Or just: cd out and back in"
echo ""
;;
esac
;;
''; '';
} }

View File

@ -1,10 +1,7 @@
# ncli/commands/git.nix — commit, push, pull, status, format # ncli/commands/git.nix — commit, push, pull, status, format
lib: lib: let
let
inherit (lib) project; inherit (lib) project;
in in {
{
commit_case = '' commit_case = ''
cd "$HOME/${project}" || { echo "Error: Could not change to $HOME/${project}"; exit 1; } cd "$HOME/${project}" || { echo "Error: Could not change to $HOME/${project}"; exit 1; }
if [ "$#" -lt 2 ]; then if [ "$#" -lt 2 ]; then
@ -20,29 +17,24 @@ in
fi fi
git add -A && git commit -m "$commit_msg" git add -A && git commit -m "$commit_msg"
;;
''; '';
push_case = '' push_case = ''
cd "$HOME/${project}" || { echo "Error: Could not change to $HOME/${project}"; exit 1; } cd "$HOME/${project}" || { echo "Error: Could not change to $HOME/${project}"; exit 1; }
git push origin $(git branch --show-current) git push origin $(git branch --show-current)
;;
''; '';
pull_case = '' pull_case = ''
cd "$HOME/${project}" || { echo "Error: Could not change to $HOME/${project}"; exit 1; } cd "$HOME/${project}" || { echo "Error: Could not change to $HOME/${project}"; exit 1; }
git pull origin $(git branch --show-current) git pull origin $(git branch --show-current)
;;
''; '';
status_case = '' status_case = ''
cd "$HOME/${project}" || { echo "Error: Could not change to $HOME/${project}"; exit 1; } cd "$HOME/${project}" || { echo "Error: Could not change to $HOME/${project}"; exit 1; }
git status git status
;;
''; '';
format_case = '' format_case = ''
nix fmt . nix fmt .
;;
''; '';
} }

View File

@ -1,10 +1,7 @@
# ncli/commands/maintenance.nix — cleanup, diag, list-gens, trim, home-backups # ncli/commands/maintenance.nix — cleanup, diag, list-gens, trim, home-backups
lib: lib: let
let
inherit (lib) project; inherit (lib) project;
in in {
{
cleanup_case = '' cleanup_case = ''
echo "Warning! This will remove old generations of your system." echo "Warning! This will remove old generations of your system."
read -p "How many generations to keep (default: all)? " keep_count read -p "How many generations to keep (default: all)? " keep_count
@ -33,7 +30,6 @@ in
echo "Cleaning up old log files..." >> "$LOG_FILE" echo "Cleaning up old log files..." >> "$LOG_FILE"
find "$LOG_DIR" -type f -mtime +3 -name "*.log" -delete >> "$LOG_FILE" 2>&1 find "$LOG_DIR" -type f -mtime +3 -name "*.log" -delete >> "$LOG_FILE" 2>&1
echo "Cleanup process logged to $LOG_FILE" echo "Cleanup process logged to $LOG_FILE"
;;
''; '';
diag_case = '' diag_case = ''
@ -50,7 +46,6 @@ in
echo "" echo ""
} > "$HOME/diag.txt" } > "$HOME/diag.txt"
echo "Diagnostic report saved to $HOME/diag.txt" echo "Diagnostic report saved to $HOME/diag.txt"
;;
''; '';
list_gens_case = '' list_gens_case = ''
@ -59,7 +54,6 @@ in
echo "" echo ""
echo "--- System Generations ---" echo "--- System Generations ---"
nix profile history --profile /nix/var/nix/profiles/system | cat || echo "Could not list system generations." nix profile history --profile /nix/var/nix/profiles/system | cat || echo "Could not list system generations."
;;
''; '';
trim_case = '' trim_case = ''
@ -73,11 +67,9 @@ in
else else
echo "Trim operation cancelled." echo "Trim operation cancelled."
fi fi
;;
''; '';
home_backups_case = '' home_backups_case = ''
ls -a ~ | grep backup ls -a ~ | grep backup
;;
''; '';
} }

View File

@ -1,10 +1,7 @@
# ncli/commands/rebuild.nix — Rebuild + Update logic # ncli/commands/rebuild.nix — Rebuild + Update logic
lib: lib: let
let
inherit (lib) host project handle_backups handle_build_error; inherit (lib) host project handle_backups handle_build_error;
in in rec {
{
# Shared rebuild snippet used by both `rebuild` and `update` # Shared rebuild snippet used by both `rebuild` and `update`
rebuild_logic = '' rebuild_logic = ''
handle_backups handle_backups
@ -21,12 +18,21 @@ in
${rebuild_logic} ${rebuild_logic}
echo -e "Starting NixOS rebuild for current host: ${host} on generation: $YELLOW$geno$NOCOLOR" echo -e "Starting NixOS rebuild for current host: ${host} on generation: $YELLOW$geno$NOCOLOR"
sudo nixos-rebuild switch --flake . ; _rebuild_exit=$? # Step 1: Build the configuration and safely update the bootloader first
set +e
sudo nixos-rebuild boot --flake .
_rebuild_exit=$?
set -e
if [ "$_rebuild_exit" -eq 0 ]; then if [ "$_rebuild_exit" -eq 0 ]; then
echo " Rebuild finished successfully for ${host}" echo " Rebuild and bootloader update finished successfully for ${host}"
# Step 2: Now that boot entries are safe, activate the system live
echo "Activating new configuration..."
sudo /nix/var/nix/profiles/system/bin/switch-to-configuration switch
if [ -n "$current" ]; then if [ -n "$current" ]; then
sudo /run/current-system/specialisation/"$current"/bin/switch-to-configuration test sudo /nix/var/nix/profiles/system/specialisation/"$current"/bin/switch-to-configuration test
else else
echo "No specialization tag found, staying on default system." echo "No specialization tag found, staying on default system."
fi fi
@ -38,7 +44,6 @@ in
echo " Rebuild failed for ${host}" >&2 echo " Rebuild failed for ${host}" >&2
exit 1 exit 1
fi fi
;;
''; '';
update_case = '' update_case = ''
@ -110,12 +115,21 @@ in
echo "Rebuilding system... Staying on current specialization" echo "Rebuilding system... Staying on current specialization"
fi fi
sudo nixos-rebuild switch --flake . ; _rebuild_exit=$? # Step 1: Build the configuration and safely update the bootloader first
set +e
sudo nixos-rebuild boot --flake .
_rebuild_exit=$?
set -e
if [ "$_rebuild_exit" -eq 0 ]; then if [ "$_rebuild_exit" -eq 0 ]; then
echo " Update and rebuild finished successfully for ${host}" echo " Update, rebuild and bootloader update finished successfully for ${host}"
# Step 2: Now that boot entries are safe, activate the system live
echo "Activating new configuration..."
sudo /nix/var/nix/profiles/system/bin/switch-to-configuration switch
if [ -n "$current" ]; then if [ -n "$current" ]; then
sudo /run/current-system/specialisation/"$current"/bin/switch-to-configuration test sudo /nix/var/nix/profiles/system/specialisation/"$current"/bin/switch-to-configuration test
else else
echo "No specialization tag found, staying on default system." echo "No specialization tag found, staying on default system."
fi fi
@ -127,6 +141,5 @@ in
echo " Update and rebuild failed for ${host}" >&2 echo " Update and rebuild failed for ${host}" >&2
exit 1 exit 1
fi fi
;;
''; '';
} }

View File

@ -1,9 +1,5 @@
# ncli/commands/switch.nix — Specialization switching # ncli/commands/switch.nix — Specialization switching
lib: lib: {
{}:
{
switch_case = '' switch_case = ''
current="" current=""
if [ -f /etc/nixos-tags ]; then if [ -f /etc/nixos-tags ]; then
@ -35,6 +31,5 @@ lib:
echo "To switch to a specialization, run: 'ncli switch <tag>'" echo "To switch to a specialization, run: 'ncli switch <tag>'"
fi fi
fi fi
;;
''; '';
} }

View File

@ -1,7 +1,3 @@
# ncli/default.nix — Entry point
# Usage in your flake:
# ncli = import ./ncli { inherit pkgs host project; };
# environment.systemPackages = [ ncli ];
{ {
pkgs, pkgs,
host, host,

View File

@ -13,64 +13,76 @@ in
# --- Backup helper --- # --- Backup helper ---
handle_backups = '' handle_backups = ''
if [ ''${#BACKUP_FILES[@]} -eq 0 ]; then handle_backups() {
echo "No backup files configured to check." echo "Checking for backup files to remove..."
return found=0
fi for file_path in "''${BACKUP_FILES[@]}"; do
full_path="$HOME/$file_path"
echo "Checking for backup files to remove..." if [ -f "$full_path" ]; then
for file_path in "''${BACKUP_FILES[@]}"; do echo "Removing stale backup file: $full_path"
full_path="$HOME/$file_path" rm "$full_path"
if [ -f "$full_path" ]; then found=1
echo "Removing stale backup file: $full_path" fi
rm "$full_path" done
if [ "$found" -eq 0 ]; then
echo "No stale backup files found."
fi fi
done }
''; '';
# --- OOM / build error handler --- # --- OOM / build error handler ---
handle_build_error = '' handle_build_error = ''
local exit_code=$? handle_build_error() {
if [ "$exit_code" -eq 137 ]; then local exit_code=$?
echo "" if [ "$exit_code" -eq 137 ]; then
echo -e "''${RED}''${NOCOLOR}" echo ""
echo -e "''${RED} BUILD KILLED Signal 9 (SIGKILL) detected ''${NOCOLOR}" echo -e "''${RED}''${NOCOLOR}"
echo -e "''${RED}''${NOCOLOR}" echo -e "''${RED} BUILD KILLED Signal 9 (SIGKILL) detected ''${NOCOLOR}"
echo "" echo -e "''${RED}''${NOCOLOR}"
echo -e "''${YELLOW}What happened:''${NOCOLOR}" echo ""
echo " The build process was forcefully terminated by the OS." echo -e "''${YELLOW}What happened:''${NOCOLOR}"
echo " This is almost always the Linux kernel OOM killer running out" echo " The build process was forcefully terminated by the OS."
echo " of RAM + swap during Nix evaluation or compilation." echo " This is almost always the Linux kernel OOM killer running out"
echo "" echo " of RAM + swap during Nix evaluation or compilation."
echo -e "''${YELLOW}Suggested fixes (try in order):''${NOCOLOR}" echo ""
echo "" echo -e "''${YELLOW}Suggested fixes (try in order):''${NOCOLOR}"
echo -e " ''${GREEN}1. Reduce parallel jobs''${NOCOLOR} (lowest RAM usage):" echo ""
echo " sudo nixos-rebuild switch --flake . --max-jobs 1 --cores 1" echo -e " ''${GREEN}1. Reduce parallel jobs''${NOCOLOR} (lowest RAM usage):"
echo "" echo " sudo nixos-rebuild switch --flake . --max-jobs 1 --cores 1"
echo -e " ''${GREEN}2. Confirm OOM killer fired:''${NOCOLOR}" echo ""
echo " journalctl -k --since '5 minutes ago' | grep -i oom" echo -e " ''${GREEN}2. Confirm OOM killer fired:''${NOCOLOR}"
echo "" echo " journalctl -k --since '5 minutes ago' | grep -i oom"
fi echo ""
fi
}
''; '';
# --- Print helpers (used by dev init) --- # --- Print helpers (used by dev init) ---
print_header = '' print_header = ''
echo "" print_header() {
echo -e "''${BLUE}==============================================''${NOCOLOR}" echo ""
echo -e "''${BLUE} Nix Flake Development Environment Initializer''${NOCOLOR}" echo -e "''${BLUE}==============================================''${NOCOLOR}"
echo -e "''${BLUE}==============================================''${NOCOLOR}" echo -e "''${BLUE} Nix Flake Development Environment Initializer''${NOCOLOR}"
echo "" echo -e "''${BLUE}==============================================''${NOCOLOR}"
echo ""
}
''; '';
print_success = '' print_success = ''
echo -e "''${GREEN}[OK]''${NOCOLOR} $1" print_success() {
echo -e "''${GREEN}[OK]''${NOCOLOR} $1"
}
''; '';
print_error = '' print_error = ''
echo -e "''${RED}[ERR]''${NOCOLOR} $1" print_error() {
echo -e "''${RED}[ERR]''${NOCOLOR} $1"
}
''; '';
print_info = '' print_info = ''
echo -e "''${YELLOW}[->]''${NOCOLOR} $1" print_info() {
echo -e "''${YELLOW}[->]''${NOCOLOR} $1"
}
''; '';
} }

View File

@ -1,5 +1,4 @@
{ {
config,
inputs, inputs,
pkgs, pkgs,
... ...
@ -7,11 +6,7 @@
imports = [ imports = [
]; ];
home-manager.sharedModules = [
./home.nix
];
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
hyprpaper inputs.noctalia.packages.${pkgs.stdenv.hostPlatform.system}.default
]; ];
} }

View File

@ -0,0 +1,9 @@
{inputs, ...}: {
imports = [
inputs.noctalia.homeModules.default
];
programs.noctalia = {
enable = true;
};
}

View File

@ -15,9 +15,15 @@
stylix = { stylix = {
enable = true; enable = true;
autoEnable = false; #So I can choose my programs it targets myself! autoEnable = false; #So I can choose my programs it targets myself!
#image = ../../other/wallpaper2.png; #image = "${inputs.cookiez-assets}/wallpapers/beach-forest.png";
#autoEnable = true; #Auto generate theme based on wallpaper #polarity = "dark"; # "dark" or "light"
base16Scheme = "${pkgs.base16-schemes}/share/themes/dracula.yaml"; base16Scheme = "${pkgs.base16-schemes}/share/themes/dracula.yaml";
#override = {
# base05 = "e0e0e0"; # default text — light grey (no # prefix!)
# base04 = "b0b0b0"; # secondary/muted text
# base06 = "f5f5f5"; # lighter text variant
#};
opacity = { opacity = {
desktop = 0.5; desktop = 0.5;
terminal = 0.9; terminal = 0.9;
@ -43,7 +49,8 @@
plymouth.logoAnimated = true; plymouth.logoAnimated = true;
console.enable = true; #Default console without desktop environment! (NOT KITTY!) console.enable = true; #Default console without desktop environment! (NOT KITTY!)
grub.enable = false; grub.enable = false;
#qt.enable = false; qt.enable = true;
gtk.enable = true;
}; };
}; };
} }

View File

@ -5,6 +5,7 @@
... ...
}: { }: {
imports = [ imports = [
inputs.niri.homeModules.stylix
]; ];
services = { services = {
@ -16,10 +17,9 @@
#firefox = { #firefox = {
# enable = true; # enable = true;
# colorTheme.enable = true; # colorTheme.enable = true;
# profileNames = [ "${username}" ]; # profileNames = ["${username}"];
#}; #};
qt.enable = false; niri.enable = true;
qt.platform = "kde";
#kde.enable = false; #kde.enable = false;
}; };
}; };

View File

@ -1,153 +0,0 @@
{
"layer": "top",
"position": "top",
"modules-left": [
"custom/launcher",
"hyprland/workspaces",
"cpu",
"memory"
],
"modules-center": [
"hyprland/window"
],
"spacing": 4,
"modules-right": [
"tray",
"wireplumber",
"network",
"backlight",
"clock",
"battery",
"custom/power"
],
"backlight": {
"device": "intel_backlight",
"format": "{percent}% {icon}",
"format-icons": ["", ""]
},
"hyprland/workspaces": {
"format": "{name}",
"persistent-workspaces": {
"1": [],
"2": [],
"3": []
}
},
"hyprland/window": {
"icon": false,
"separate-outputs": true,
"format": "{}"
},
"tray": {
"icon-size": 15,
"spacing": 7
},
"clock": {
"format": "{:%H:%M} ",
"format-alt": "{:%A, %B %d, %Y (%R)}",
"tooltip-format": "<tt><small>{calendar}</small></tt>",
"calendar": {
"mode": "year",
"mode-mon-col": 3,
"weeks-pos": "right",
"on-scroll": 1,
"on-click-right": "mode",
"format": {
"months": "<span color='#f5e0dc'><b>{}</b></span>",
"days": "<span color='#cdd6f4'><b>{}</b></span>",
"weeks": "<span color='#fab387'><b>W{}</b></span>",
"weekdays": "<span color='#f5c2e7'><b>{}</b></span>",
"today": "<span color='#cba6f7'><b><u>{}</u></b></span>"
}
},
"actions": {
"on-click-right": "mode",
"on-click-forward": "tz_up",
"on-click-backward": "tz_down",
"on-scroll-up": "shift_up",
"on-scroll-down": "shift_down"
}
},
"cpu": {
"interval": 1,
"format": "CPU {usage:>2}% {icon0}{icon1}{icon2}{icon3}",
"format-icons": [
"▁",
"▂",
"▃",
"▄",
"▅",
"▆",
"▇",
"█"
],
"on-click": "kitty -e btop"
},
"memory": {
"interval": 30,
"format": "MEM {used:0.1f}G/{total:0.1f}G"
},
"network": {
"format": "󰤭 Disabled",
"format-wifi": " ",
"format-ethernet": " 󰈀 ",
"format-disconnected": "⚠",
"tooltip": true,
"tooltip-format": "{ifname}\n{ipaddr}",
"tooltip-format-wifi": "{essid} {ifname}\n{ipaddr}\nstrength: {signalStrength}%",
"on-click": "networkmanager_dmenu"
},
"custom/launcher": {
"format": " 󰣇 ",
"tooltip": false,
"on-click": "wofi -c ~/.config/wofi/config -I"
},
"custom/power": {
"format": "  ",
"on-click": "~/.config/wofi/scripts/power.sh",
"tooltip": false
},
"wireplumber": {
"scroll-step": 10,
"format": "{volume}% {icon} ",
"format-bluetooth": "{icon} {volume}%",
"format-muted": "muted ",
"on-click": "pavucontrol",
"format-icons": {
"headphones": "",
"handsfree": "",
"headset": "",
"phone": "",
"portable": "",
"car": "",
"default": [
"",
"󰓃"
]
}
},
"battery": {
"states": {
"warning": 30,
"critical": 15
},
"format": "{capacity}% {icon}",
"format-charging": "󰂄 {capacity}%",
"format-pluged": "󱟦 {capacity}%",
"format-full": "󰁹 {capacity}%",
"format-icons": [
"󰂎",
"󰁺",
"󰁻",
"󰁼",
"󰁽",
"󰁾",
"󰁿",
"󰂀",
"󰂁",
"󰂂",
"󰁹"
]
}
}

View File

@ -1,4 +0,0 @@
{...}: {
# xdg.configFile."waybar/config.jsonc".source = ./config.jsonc;
# xdg.configFile."waybar/style.css".source = ./style.css;
}

View File

@ -1,167 +0,0 @@
* {
font-family: "JetBrainsMono Nerd Font", sans-serif;
font-size: 13px;
}
window#waybar {
background-color: transparent;
}
window > box {
margin-top: 0px;
margin-left: 10px;
margin-right: 10px;
padding-left: 4px;
padding-right: 4px;
}
#window {
background-color: #202020;
border-radius: 20px;
padding: 8px 12px 8px 8px;
margin: 0px 0;
}
window#waybar.empty #window {
background: rgba(12, 12, 12, 0);
}
.modules-left {
padding: 3px;
}
.modules-right {
padding: 3px;
}
.modules-center {
padding: 3px;
}
#workspaces {
background-color: #202020;
border-radius: 20px;
padding: 4px 4px 4px 6px;
margin: 4px 0;
}
#workspaces button {
min-height: 0;
padding: 0 7px;
margin-right: 2px;
color: #f5e0dc;
}
#workspaces button.urgent {
color: #f5e0dc;
animation-name: blink;
animation-duration: 0.5s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
#workspaces button.empty {
color: #cdd6f4;
}
#workspaces button.visible {
color: #89dceb;
}
#workspaces button.active {
color: #fab387;
}
@keyframes blink {
to {
color: #202020;
background-color: #dcf5f3;
}
}
#custom-launcher {
background-color: #202020;
border-radius: 20px;
padding: 8px 8px 8px 4px;
margin: 4px 0;
color: #89dceb;
}
#custom-power {
background-color: #202020;
border-radius: 20px;
padding: 8px 12px 8px 8px;
margin: 4px 0;
}
#cpu {
background-color: #202020;
border-radius: 20px;
padding: 8px 8px 8px 20px;
margin: 4px 0;
color: #f2cdcd;
}
#memory {
background-color: #202020;
border-radius: 20px;
padding: 8px 8px 8px 20px;
margin: 4px 0;
color: #fab387;
}
#wireplumber {
background-color: #202020;
border-radius: 20px;
padding: 8px 8px 8px 20px;
margin: 4px 0;
color: #f9e2af;
}
#wireplumber.muted {
color: #f38ba8;
}
#clock {
background-color: #202020;
border-radius: 20px;
padding: 8px 10px 10px 10px;
margin: 4px 0;
color: #94e2d5;
}
#network {
background-color: #202020;
color: #cdd6f4;
border-radius: 20px;
padding: 8px;
margin: 4px 0;
}
#network.disabled {
color: #f38ba8;
}
#tray {
background-color: #202020;
border-radius: 20px;
padding: 8px 12px 8px 12px;
margin: 4px 0;
}
#battery {
background-color: #202020;
color: #cdd6f4;
border-radius: 20px;
padding: 8px;
margin: 4px 0;
}
#backlight {
background-color: #202020;
color: #cdd6f4;
border-radius: 20px;
padding: 8px;
margin: 4px 0;
}

View File

@ -1,5 +1,6 @@
{ {
config, config,
inputs,
pkgs, pkgs,
username, username,
project, project,
@ -7,31 +8,8 @@
}: { }: {
#To show logs of services run: #To show logs of services run:
#journalctl --user-unit={service-name} --user #journalctl --user-unit={service-name} --user
systemd.user.services.niri-waybar = {
description = "Waybar status bar for Niri";
# "wantedBy" replaces the [Install] section # The Niri Session Cleanup Service
wantedBy = ["graphical-session.target"];
# "partOf" and "after" replace the [Unit] section dependencies
partOf = ["graphical-session.target"];
after = ["graphical-session.target"];
# [Unit] configuration goes here
unitConfig = {
# This checks the environment variable to ensure we are in Niri
ConditionEnvironment = "XDG_CURRENT_DESKTOP=niri";
};
# [Service] configuration goes here
serviceConfig = {
ExecStart = "${pkgs.waybar}/bin/waybar";
Restart = "on-failure";
RestartSec = "1s";
};
};
# 2. The Niri Session Cleanup Service
# This service starts when the graphical session starts, and when it stops, # This service starts when the graphical session starts, and when it stops,
# it forcibly stops the graphical-session.target to ensure a clean state for the next login. # it forcibly stops the graphical-session.target to ensure a clean state for the next login.
systemd.user.services.niri-session-manager = { systemd.user.services.niri-session-manager = {

View File

@ -2,12 +2,12 @@
config, config,
inputs, inputs,
pkgs, pkgs,
system,
... ...
}: { }: {
imports = [ imports = [
./autostart.nix ./autostart.nix
../modules/hyprlock ../modules/hyprlock
../modules/hyprpaper
../modules/stylix ../modules/stylix
]; ];
@ -16,10 +16,8 @@
]; ];
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
#mako
fuzzel
waybar
xwayland-satellite xwayland-satellite
lxsession #Needed for things like gparted
]; ];
programs = { programs = {
@ -33,7 +31,6 @@
#services.xserver.displayManager.sddm.enable = true; #services.xserver.displayManager.sddm.enable = true;
xdg.portal = { xdg.portal = {
#Needed for waybar
enable = true; enable = true;
extraPortals = [pkgs.xdg-desktop-portal-gtk pkgs.xdg-desktop-portal-wlr]; extraPortals = [pkgs.xdg-desktop-portal-gtk pkgs.xdg-desktop-portal-wlr];
config.common.default = "*"; config.common.default = "*";

View File

@ -5,31 +5,13 @@
}: { }: {
imports = [ imports = [
inputs.niri.homeModules.niri inputs.niri.homeModules.niri
../modules/waybar/home.nix ../modules/noctalia/home.nix
]; ];
xdg.configFile."mako/config".text = ''
default-timeout=5000
ignore-timeout=1
'';
programs.niri = { programs.niri = {
package = pkgs.niri; package = pkgs.niri;
enable = true; enable = true;
#xwayland.enable = true;
# config = ''
# binds {
# Super+Return { spawn "kitty"; }
# Super+Space { spawn "fuzzel"; }
# Super+Q { close-window; }
# Super+Left { focus-column-left; }
# Super+Right { focus-column-right; }
# Super+Up { focus-workspace-up; }
# Super+Down { focus-workspace-down; }
# Super+L { spawn "hyprlock"; }
# Super+Shift+E { "quit"; }
# }
# '';
config = '' config = ''
input { input {
keyboard { keyboard {
@ -38,6 +20,10 @@
} }
numlock numlock
} }
mouse {
accel-profile "flat"
accel-speed -0.4
}
} }
prefer-no-csd prefer-no-csd
@ -83,11 +69,8 @@
} }
} }
// spawn-at-startup "waybar" spawn-at-startup "noctalia"
spawn-at-startup "hyprpaper" spawn-at-startup "lxpolkit"
spawn-at-startup "${pkgs.mako}/bin/mako"
// spawn-sh-at-startup "qs -c ~/source/qs/MyAwesomeShell"
hotkey-overlay { hotkey-overlay {
// Uncomment this line to disable the "Important Hotkeys" pop-up at startup. // Uncomment this line to disable the "Important Hotkeys" pop-up at startup.
@ -102,6 +85,11 @@
draw-border-with-background false draw-border-with-background false
} }
// layer-rule {
// match namespace="^awww-daemonbackdrop$"
// place-within-backdrop true
// }
output "eDP-1" { output "eDP-1" {
mode "2880x1920@120.000" mode "2880x1920@120.000"
scale 2 scale 2
@ -111,24 +99,26 @@
binds { binds {
Mod+Shift+Minus { show-hotkey-overlay; } Mod+Shift+Minus { show-hotkey-overlay; }
Mod+Shift+S hotkey-overlay-title="Make a screenshot selection" { spawn-sh "noctalia msg screenshot-region";}
Mod+T hotkey-overlay-title="Open a Terminal: kitty" { spawn "kitty"; } Mod+T hotkey-overlay-title="Open a Terminal: kitty" { spawn "kitty"; }
Mod+D hotkey-overlay-title="Run an Application: fuzzel" { spawn "fuzzel"; } Mod+D hotkey-overlay-title="Run an Application" { spawn-sh "noctalia msg panel-toggle launcher"; }
Super+L hotkey-overlay-title="Lock the Screen: hyprlock" { spawn "hyprlock"; } Super+L hotkey-overlay-title="Lock the Screen" { spawn-sh "noctalia msg session lock"; }
Super+Alt+S allow-when-locked=true hotkey-overlay-title=null { spawn-sh "pkill orca || exec orca"; } Super+Alt+S allow-when-locked=true hotkey-overlay-title=null { spawn-sh "pkill orca || exec orca"; }
XF86AudioRaiseVolume allow-when-locked=true { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1+ -l 1.0"; } XF86AudioRaiseVolume allow-when-locked=true { spawn-sh "noctalia msg volume-up"; }
XF86AudioLowerVolume allow-when-locked=true { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1-"; } XF86AudioLowerVolume allow-when-locked=true { spawn-sh "noctalia msg volume-down"; }
XF86AudioMute allow-when-locked=true { spawn-sh "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; } XF86AudioMute allow-when-locked=true { spawn-sh "noctalia msg volume-mute"; }
XF86AudioMicMute allow-when-locked=true { spawn-sh "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"; } XF86AudioMicMute allow-when-locked=true { spawn-sh "noctalia msg mic-mute"; }
XF86AudioPlay allow-when-locked=true { spawn-sh "playerctl play-pause"; } XF86AudioPlay allow-when-locked=true { spawn-sh "playerctl play-pause"; }
XF86AudioStop allow-when-locked=true { spawn-sh "playerctl stop"; } XF86AudioStop allow-when-locked=true { spawn-sh "playerctl stop"; }
XF86AudioPrev allow-when-locked=true { spawn-sh "playerctl previous"; } XF86AudioPrev allow-when-locked=true { spawn-sh "playerctl previous"; }
XF86AudioNext allow-when-locked=true { spawn-sh "playerctl next"; } XF86AudioNext allow-when-locked=true { spawn-sh "playerctl next"; }
XF86MonBrightnessUp allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "+10%"; } XF86MonBrightnessUp allow-when-locked=true { spawn-sh "noctalia msg brightness-up"; }
XF86MonBrightnessDown allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "10%-"; } XF86MonBrightnessDown allow-when-locked=true { spawn-sh "noctalia msg brightness-down"; }
Mod+O repeat=false { toggle-overview; } Mod+O repeat=false { toggle-overview; }

View File

@ -12,6 +12,11 @@
description = "Automatically start Yakuake"; description = "Automatically start Yakuake";
after = ["graphical-session.target"]; after = ["graphical-session.target"];
wantedBy = ["graphical-session.target"]; wantedBy = ["graphical-session.target"];
unitConfig = {
ConditionEnvironment = "XDG_CURRENT_DESKTOP=KDE";
};
serviceConfig = { serviceConfig = {
ExecStart = ["${pkgs.kdePackages.yakuake}/bin/yakuake"]; ExecStart = ["${pkgs.kdePackages.yakuake}/bin/yakuake"];