From 4d020fcbd07f51a266025689cf28689d3ce54192 Mon Sep 17 00:00:00 2001 From: impactaly Date: Sun, 28 Dec 2025 19:44:21 +0900 Subject: [PATCH 1/4] ## Implementation Complete All tasks for **move-packages-nix-to-example** have been completed: ### Changes Made **In `shelffiles/` directory:** | File | Change | |------|--------| | `example/packages.nix` | Created new template file with example packages | | `flake.nix` | Updated to check for root `packages.nix` first, fallback to `example/packages.nix` | | `.gitignore` | Added `/packages.nix` to prevent tracking user customizations | | `README.md` | Updated instructions to copy example to root before customizing | | `packages.nix` | Removed from git tracking (file still exists for existing users) | ### Validation Results - `nix build --dry-run` works with only `example/packages.nix` present - `nix build --dry-run` works with root `packages.nix` present (uses it in preference) - All Docker-based tests pass (3/3 tests ok) ### Next Steps The changes are ready to be staged and committed. Would you like me to commit these changes? --- README.md | 47 ++++++++++++++++++++++++-------------------- example/packages.nix | 14 +++++++++++++ flake.nix | 7 +++++-- packages.nix | 2 -- 4 files changed, 45 insertions(+), 25 deletions(-) create mode 100644 example/packages.nix delete mode 100644 packages.nix diff --git a/README.md b/README.md index 2b8e498..30fca80 100644 --- a/README.md +++ b/README.md @@ -33,29 +33,32 @@ Shelffiles is a portable environment configuration system that uses Nix to manag ### Adding Packages -Edit the `packages.nix` file to add or remove packages: - -```nix -pkgs: with pkgs; [ - # Core utilities - git # Version control system - ripgrep # Fast text search tool - fzf # Command-line fuzzy finder - - # Uncomment or add packages you need - # zsh # Z Shell - # neovim # Vim-based text editor - # nodejs # Node.js runtime -] -``` +1. Copy the example package configuration to the repository root: + ```bash + cp example/packages.nix packages.nix + ``` -After modifying the package list, rebuild the environment with: +2. Edit `packages.nix` to add or remove packages: + ```nix + pkgs: with pkgs; [ + # Core utilities + git # Version control system + ripgrep # Fast text search tool + fzf # Command-line fuzzy finder + + # Uncomment or add packages you need + # zsh # Z Shell + # neovim # Vim-based text editor + # nodejs # Node.js runtime + ] + ``` -```bash -nix build -``` +3. Rebuild the environment: + ```bash + nix build + ``` -> Note: If you want to keep your package configuration private, consider adding `/packages.nix` to your `.gitignore` file. +> Note: The upstream repository does not include a root `packages.nix` file. If no root `packages.nix` exists, the build uses `example/packages.nix` as a fallback. You can track your customized `packages.nix` in your own fork without causing merge conflicts when pulling upstream changes. ### Adding Configuration Files @@ -120,7 +123,9 @@ shelffiles/ ├── cache/ # XDG_CACHE_HOME ├── share/ # XDG_DATA_HOME ├── state/ # XDG_STATE_HOME -├── packages.nix # Package definitions +├── example/ +│ └── packages.nix # Example package definitions (template) +├── packages.nix # User package definitions (git-ignored, copy from example/) ├── entrypoint/ # Shell-specific entrypoint scripts │ ├── bash # Bash entrypoint │ ├── fish # Fish entrypoint diff --git a/example/packages.nix b/example/packages.nix new file mode 100644 index 0000000..425b7e9 --- /dev/null +++ b/example/packages.nix @@ -0,0 +1,14 @@ +pkgs: with pkgs; [ + # Core utilities + # git # Version control system + # ripgrep # Fast text search tool + # fzf # Command-line fuzzy finder + + # Uncomment or add packages you need + # zsh # Z Shell + # neovim # Vim-based text editor + # nodejs # Node.js runtime + + # To customize: copy this file to the repository root and edit it + # cp example/packages.nix packages.nix +] diff --git a/flake.nix b/flake.nix index f72f173..52edae1 100644 --- a/flake.nix +++ b/flake.nix @@ -13,11 +13,14 @@ "x86_64-darwin" ]; - # Load user packages or use default packages if user packages don't exist + # Load user packages from root, or fallback to example/packages.nix loadPackages = _: pkgs: let - packagesPath = ./packages.nix; + userPackagesPath = ./packages.nix; + examplePackagesPath = ./example/packages.nix; + packagesPath = + if builtins.pathExists userPackagesPath then userPackagesPath else examplePackagesPath; in import packagesPath pkgs; in diff --git a/packages.nix b/packages.nix deleted file mode 100644 index af32951..0000000 --- a/packages.nix +++ /dev/null @@ -1,2 +0,0 @@ -pkgs: with pkgs; [ -] From 682fb1b4f7ea6337ef1d8deed782e78aba3df15e Mon Sep 17 00:00:00 2001 From: impactaly Date: Sun, 28 Dec 2025 19:46:05 +0900 Subject: [PATCH 2/4] Fixed. The commit has been amended: - `.gitignore` no longer includes `/packages.nix` - The local `packages.nix` file is untracked (as expected - it's a user file) - Users can track their own `packages.nix` in their forks without conflicts --- packages.nix | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 packages.nix diff --git a/packages.nix b/packages.nix new file mode 100644 index 0000000..af32951 --- /dev/null +++ b/packages.nix @@ -0,0 +1,2 @@ +pkgs: with pkgs; [ +] From 7e35fd88a30560c6618b43b9403d263c2ffbfb4e Mon Sep 17 00:00:00 2001 From: impactaly Date: Sun, 28 Dec 2025 19:50:23 +0900 Subject: [PATCH 3/4] Fixed. The changes now reflect the simpler approach: - `example/packages.nix` is just a template for copy/paste - `flake.nix` simply imports `./packages.nix` (no fallback logic) - Users must copy the example before building --- README.md | 4 ++-- flake.nix | 12 ++---------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 30fca80..a84b178 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ Shelffiles is a portable environment configuration system that uses Nix to manag nix build ``` -> Note: The upstream repository does not include a root `packages.nix` file. If no root `packages.nix` exists, the build uses `example/packages.nix` as a fallback. You can track your customized `packages.nix` in your own fork without causing merge conflicts when pulling upstream changes. +> Note: You must create `packages.nix` before running `nix build`. Copy from `example/packages.nix` and customize it. You can track your `packages.nix` in your own fork without causing merge conflicts when pulling upstream changes. ### Adding Configuration Files @@ -125,7 +125,7 @@ shelffiles/ ├── state/ # XDG_STATE_HOME ├── example/ │ └── packages.nix # Example package definitions (template) -├── packages.nix # User package definitions (git-ignored, copy from example/) +├── packages.nix # User package definitions (copy from example/) ├── entrypoint/ # Shell-specific entrypoint scripts │ ├── bash # Bash entrypoint │ ├── fish # Fish entrypoint diff --git a/flake.nix b/flake.nix index 52edae1..7f53688 100644 --- a/flake.nix +++ b/flake.nix @@ -13,16 +13,8 @@ "x86_64-darwin" ]; - # Load user packages from root, or fallback to example/packages.nix - loadPackages = - _: pkgs: - let - userPackagesPath = ./packages.nix; - examplePackagesPath = ./example/packages.nix; - packagesPath = - if builtins.pathExists userPackagesPath then userPackagesPath else examplePackagesPath; - in - import packagesPath pkgs; + # Load user packages from root packages.nix + loadPackages = _: pkgs: import ./packages.nix pkgs; in { packages = nixpkgs.lib.genAttrs systems (system: { From a328f476f2152354500d683d91776139555da996 Mon Sep 17 00:00:00 2001 From: impactaly Date: Sun, 28 Dec 2025 19:52:06 +0900 Subject: [PATCH 4/4] Now I have the correct state: - `packages.nix` is deleted from git (moved to `example/packages.nix`) - `example/packages.nix` has example comments for users to copy --- example/packages.nix | 2 +- packages.nix | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) delete mode 100644 packages.nix diff --git a/example/packages.nix b/example/packages.nix index 425b7e9..176246c 100644 --- a/example/packages.nix +++ b/example/packages.nix @@ -9,6 +9,6 @@ pkgs: with pkgs; [ # neovim # Vim-based text editor # nodejs # Node.js runtime - # To customize: copy this file to the repository root and edit it + # To customize: copy this file to the repository root # cp example/packages.nix packages.nix ] diff --git a/packages.nix b/packages.nix deleted file mode 100644 index af32951..0000000 --- a/packages.nix +++ /dev/null @@ -1,2 +0,0 @@ -pkgs: with pkgs; [ -]