From afb4b628273513c82fe1e6d4e7d84590abae866a Mon Sep 17 00:00:00 2001 From: Kiana Sheibani Date: Sun, 23 Nov 2025 22:43:24 -0500 Subject: [PATCH 1/2] change basically everything It's a good thing that I'm not collaborating with anyone on this repository, because this is REALLY bad practice. --- .gitignore | 5 ++- LICENSE | 2 +- bash/nixpkgs/flake.lock | 43 ------------------- bash/nixpkgs/flake.nix | 4 +- bash/nixpkgs/hello | 3 ++ bash/nixpkgs/package.nix | 10 ++--- bash/nixpkgs/soe | 24 ----------- fish/nixpkgs/flake.lock | 43 ------------------- fish/nixpkgs/flake.nix | 4 +- fish/nixpkgs/hello | 3 ++ fish/nixpkgs/package.nix | 10 ++--- fish/nixpkgs/soe | 19 -------- flake.nix | 2 +- python/nixpkgs/.envrc | 3 +- python/nixpkgs/bin/soe | 4 -- python/nixpkgs/flake.lock | 6 +-- python/nixpkgs/flake.nix | 10 ++++- python/nixpkgs/package.nix | 10 +++-- python/nixpkgs/pyproject.toml | 10 +++++ python/nixpkgs/setup.py | 7 --- python/nixpkgs/shell.nix | 9 +++- python/nixpkgs/soe/main.py | 18 -------- python/nixpkgs/{soe => src/hello}/__init__.py | 0 python/nixpkgs/src/hello/main.py | 6 +++ 24 files changed, 68 insertions(+), 187 deletions(-) delete mode 100644 bash/nixpkgs/flake.lock create mode 100755 bash/nixpkgs/hello delete mode 100755 bash/nixpkgs/soe delete mode 100644 fish/nixpkgs/flake.lock create mode 100755 fish/nixpkgs/hello delete mode 100755 fish/nixpkgs/soe delete mode 100755 python/nixpkgs/bin/soe create mode 100644 python/nixpkgs/pyproject.toml delete mode 100644 python/nixpkgs/setup.py delete mode 100644 python/nixpkgs/soe/main.py rename python/nixpkgs/{soe => src/hello}/__init__.py (100%) create mode 100644 python/nixpkgs/src/hello/main.py diff --git a/.gitignore b/.gitignore index 3d4575f..09e9e2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ result* -.direnv +.direnv/ + +flake.lock +!/flake.lock diff --git a/LICENSE b/LICENSE index a5d8715..141fcbf 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Kiana Sheibani +Copyright (c) 2025 Kiana Sheibani Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/bash/nixpkgs/flake.lock b/bash/nixpkgs/flake.lock deleted file mode 100644 index 45fde49..0000000 --- a/bash/nixpkgs/flake.lock +++ /dev/null @@ -1,43 +0,0 @@ -{ - "nodes": { - "nixpkgs": { - "locked": { - "lastModified": 1722073938, - "narHash": "sha256-OpX0StkL8vpXyWOGUD6G+MA26wAXK6SpT94kLJXo6B4=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "e36e9f57337d0ff0cf77aceb58af4c805472bfae", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "nixpkgs": "nixpkgs", - "systems": "systems" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/bash/nixpkgs/flake.nix b/bash/nixpkgs/flake.nix index 9505679..266f871 100644 --- a/bash/nixpkgs/flake.nix +++ b/bash/nixpkgs/flake.nix @@ -10,8 +10,8 @@ packages = eachSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; in { - soe = pkgs.callPackage ./package.nix {}; - default = self.packages.${system}.soe; + hello = pkgs.callPackage ./package.nix {}; + default = self.packages.${system}.hello; }); }; } diff --git a/bash/nixpkgs/hello b/bash/nixpkgs/hello new file mode 100755 index 0000000..86f1c62 --- /dev/null +++ b/bash/nixpkgs/hello @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +echo "Hello, World!" diff --git a/bash/nixpkgs/package.nix b/bash/nixpkgs/package.nix index 20e14bc..458a1ce 100644 --- a/bash/nixpkgs/package.nix +++ b/bash/nixpkgs/package.nix @@ -1,10 +1,10 @@ -{ stdenv +{ stdenvNoCC , bash }: -stdenv.mkDerivation { - pname = "soe"; - version = "1.0"; +stdenvNoCC.mkDerivation { + pname = "hello"; + version = "0.1"; src = ./.; @@ -12,6 +12,6 @@ stdenv.mkDerivation { installPhase = '' mkdir -p $out/bin - cp soe $out/bin + cp hello $out/bin ''; } diff --git a/bash/nixpkgs/soe b/bash/nixpkgs/soe deleted file mode 100755 index e861d8f..0000000 --- a/bash/nixpkgs/soe +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -echo -n "Primes up to: " -read num -echo - -nums=() -for i in `seq 2 $num`; do - nums+=($i) -done - -unset nums[-1] - -while [ -n "$nums" ]; do - prime=${nums[0]} - echo -n "$prime " - nums_=() - for elem in "${nums[@]}"; do - [ $(( $elem % $prime )) -eq 0 ] || nums_+=($elem) - done - nums=(${nums_[@]}) -done - -echo diff --git a/fish/nixpkgs/flake.lock b/fish/nixpkgs/flake.lock deleted file mode 100644 index c44d5a5..0000000 --- a/fish/nixpkgs/flake.lock +++ /dev/null @@ -1,43 +0,0 @@ -{ - "nodes": { - "nixpkgs": { - "locked": { - "lastModified": 1722141560, - "narHash": "sha256-Ul3rIdesWaiW56PS/Ak3UlJdkwBrD4UcagCmXZR9Z7Y=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "038fb464fcfa79b4f08131b07f2d8c9a6bcc4160", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "nixpkgs": "nixpkgs", - "systems": "systems" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/fish/nixpkgs/flake.nix b/fish/nixpkgs/flake.nix index 9505679..266f871 100644 --- a/fish/nixpkgs/flake.nix +++ b/fish/nixpkgs/flake.nix @@ -10,8 +10,8 @@ packages = eachSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; in { - soe = pkgs.callPackage ./package.nix {}; - default = self.packages.${system}.soe; + hello = pkgs.callPackage ./package.nix {}; + default = self.packages.${system}.hello; }); }; } diff --git a/fish/nixpkgs/hello b/fish/nixpkgs/hello new file mode 100755 index 0000000..98ecd49 --- /dev/null +++ b/fish/nixpkgs/hello @@ -0,0 +1,3 @@ +#!/usr/bin/env fish + +echo "Hello, World!" diff --git a/fish/nixpkgs/package.nix b/fish/nixpkgs/package.nix index aaeb6d2..6e6dcde 100644 --- a/fish/nixpkgs/package.nix +++ b/fish/nixpkgs/package.nix @@ -1,10 +1,10 @@ -{ stdenv +{ stdenvNoCC , fish }: -stdenv.mkDerivation { - pname = "soe"; - version = "1.0"; +stdenvNoCC.mkDerivation { + pname = "hello"; + version = "0.1"; src = ./.; @@ -12,6 +12,6 @@ stdenv.mkDerivation { installPhase = '' mkdir -p $out/bin - cp soe $out/bin + cp hello $out/bin ''; } diff --git a/fish/nixpkgs/soe b/fish/nixpkgs/soe deleted file mode 100755 index 5cc2b5a..0000000 --- a/fish/nixpkgs/soe +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env fish - -read -P "Primes up to: " num -echo - -set nums (seq 2 $num)[..-2] - -while test -n "$nums" - set prime $nums[1] - echo -n "$prime " - - set -e nums_ - for elem in $nums - test (math $elem % $prime) -eq 0 || set -a nums_ $elem - end - set nums $nums_ -end - -echo diff --git a/flake.nix b/flake.nix index 6164411..1ade558 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "Templates of the Sieve of Eratosthenes implemented in various languages"; + description = "Hello World flake templates for various languages and build systems"; outputs = { self, ... }: let diff --git a/python/nixpkgs/.envrc b/python/nixpkgs/.envrc index e4c941b..af0cc93 100644 --- a/python/nixpkgs/.envrc +++ b/python/nixpkgs/.envrc @@ -1,3 +1,2 @@ #!/usr/bin/env bash - -use flake ..#python +use flake diff --git a/python/nixpkgs/bin/soe b/python/nixpkgs/bin/soe deleted file mode 100755 index 9ef8dcc..0000000 --- a/python/nixpkgs/bin/soe +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env python - -import soe -soe.main() diff --git a/python/nixpkgs/flake.lock b/python/nixpkgs/flake.lock index c44d5a5..fdd658c 100644 --- a/python/nixpkgs/flake.lock +++ b/python/nixpkgs/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1722141560, - "narHash": "sha256-Ul3rIdesWaiW56PS/Ak3UlJdkwBrD4UcagCmXZR9Z7Y=", + "lastModified": 1763618868, + "narHash": "sha256-v5afmLjn/uyD9EQuPBn7nZuaZVV9r+JerayK/4wvdWA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "038fb464fcfa79b4f08131b07f2d8c9a6bcc4160", + "rev": "a8d610af3f1a5fb71e23e08434d8d61a466fc942", "type": "github" }, "original": { diff --git a/python/nixpkgs/flake.nix b/python/nixpkgs/flake.nix index 9505679..0c2dc0d 100644 --- a/python/nixpkgs/flake.nix +++ b/python/nixpkgs/flake.nix @@ -10,8 +10,14 @@ packages = eachSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; in { - soe = pkgs.callPackage ./package.nix {}; - default = self.packages.${system}.soe; + hello = pkgs.callPackage ./package.nix {}; + default = self.packages.${system}.hello; + }); + + devShells = eachSystem (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in { + default = pkgs.callPackage ./shell.nix {}; }); }; } diff --git a/python/nixpkgs/package.nix b/python/nixpkgs/package.nix index 961c388..85fcc64 100644 --- a/python/nixpkgs/package.nix +++ b/python/nixpkgs/package.nix @@ -1,9 +1,13 @@ -{ python3 }: +{ python3 +}: python3.pkgs.buildPythonApplication { - pname = "soe"; - version = "1.0"; + pname = "hello"; + version = "0.1"; src = ./.; + pyproject = true; + build-system = [ python3.pkgs.setuptools ]; + doCheck = false; } diff --git a/python/nixpkgs/pyproject.toml b/python/nixpkgs/pyproject.toml new file mode 100644 index 0000000..07e8dfb --- /dev/null +++ b/python/nixpkgs/pyproject.toml @@ -0,0 +1,10 @@ +[project] +name = "hello" +version = "0.1.0" + +[project.scripts] +hello = "hello:main" + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" diff --git a/python/nixpkgs/setup.py b/python/nixpkgs/setup.py deleted file mode 100644 index 158092b..0000000 --- a/python/nixpkgs/setup.py +++ /dev/null @@ -1,7 +0,0 @@ -from setuptools import setup - -setup( - name="soe", - version="1.0.0", - scripts=["bin/soe"] -) diff --git a/python/nixpkgs/shell.nix b/python/nixpkgs/shell.nix index 332eaff..4a7e9e5 100644 --- a/python/nixpkgs/shell.nix +++ b/python/nixpkgs/shell.nix @@ -1,3 +1,8 @@ -{ python3 }: +{ mkShell +, python3 +}: -python3.buildEnv.env +mkShell { + inputsFrom = [ python3.buildEnv.env ]; + packages = [ python3.pkgs.python-lsp-server ]; +} diff --git a/python/nixpkgs/soe/main.py b/python/nixpkgs/soe/main.py deleted file mode 100644 index f6a1425..0000000 --- a/python/nixpkgs/soe/main.py +++ /dev/null @@ -1,18 +0,0 @@ - -def sieve_of_eratosthenes(n): - nums = list(range(2, n)) - while nums: - prime = nums[0] - nums = [i for i in nums if i % prime] - yield prime - -def main(): - num = int(input("Primes up to: ")) - print() - for i in sieve_of_eratosthenes(num): - print(i, end=" ") - print() - - -if __name__ == "__main__": - main() diff --git a/python/nixpkgs/soe/__init__.py b/python/nixpkgs/src/hello/__init__.py similarity index 100% rename from python/nixpkgs/soe/__init__.py rename to python/nixpkgs/src/hello/__init__.py diff --git a/python/nixpkgs/src/hello/main.py b/python/nixpkgs/src/hello/main.py new file mode 100644 index 0000000..b1a4c27 --- /dev/null +++ b/python/nixpkgs/src/hello/main.py @@ -0,0 +1,6 @@ + +def main(): + print("Hello, World!") + +if __name__ == "__main__": + main() From fe347d9769c28a58289fb6b49e38f621a30c190e Mon Sep 17 00:00:00 2001 From: Kiana Sheibani Date: Mon, 24 Nov 2025 02:46:53 -0500 Subject: [PATCH 2/2] restructure everything --- README.md | 46 +++++++++++++++++++ flake.nix | 41 +++++++++-------- python/nixpkgs/flake.lock | 43 ----------------- python/nixpkgs/package.nix | 13 ------ .../{nixpkgs => pyproject/nixpkgs/cli}/.envrc | 0 .../nixpkgs/cli}/flake.nix | 0 python/pyproject/nixpkgs/cli/package.nix | 20 ++++++++ .../nixpkgs/cli}/pyproject.toml | 0 .../nixpkgs/cli}/shell.nix | 0 .../nixpkgs/cli}/src/hello/__init__.py | 0 .../nixpkgs/cli}/src/hello/main.py | 0 11 files changed, 87 insertions(+), 76 deletions(-) create mode 100644 README.md delete mode 100644 python/nixpkgs/flake.lock delete mode 100644 python/nixpkgs/package.nix rename python/{nixpkgs => pyproject/nixpkgs/cli}/.envrc (100%) rename python/{nixpkgs => pyproject/nixpkgs/cli}/flake.nix (100%) create mode 100644 python/pyproject/nixpkgs/cli/package.nix rename python/{nixpkgs => pyproject/nixpkgs/cli}/pyproject.toml (100%) rename python/{nixpkgs => pyproject/nixpkgs/cli}/shell.nix (100%) rename python/{nixpkgs => pyproject/nixpkgs/cli}/src/hello/__init__.py (100%) rename python/{nixpkgs => pyproject/nixpkgs/cli}/src/hello/main.py (100%) diff --git a/README.md b/README.md new file mode 100644 index 0000000..ca4a350 --- /dev/null +++ b/README.md @@ -0,0 +1,46 @@ +# Toki's Nix Flake Template Repository + +This is my personal collection of Nix flake templates for various programming +languages and build systems. + +## Motivation + +There already exists a [semi-official repository of flake +templates](https://github.com/NixOS/templates), so why make my own? + +I have a few different reasons: + +- **Comprehensiveness:** The official template repository is rather small and + doesn't have most of the templates I would actually want to use. +- **Consistency:** The templates in the official repository are contributed by + community members, and there's very little stylistic or structural consistency + between them. +- **Preference:** The structure of a flake can be very opinionated, and most of + the official flake templates are rather poorly constructed by my standards, + often not bothering to follow established best practices. + +## Usage + +Flake templates are used with the `nix flake init` command: + +```sh +nix flake init -t git+https://git.tokinanpa.dev/toki/templates#