Skip to content

feat: Nix Shell #799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8120a1b
finished basic devShell for the flake
maningreen Mar 31, 2025
d21b295
chore: removed *.nix from gitignore
Mar 31, 2025
58adc4a
chore: flake description
Mar 31, 2025
38408a1
refactor: flake inputs
Mar 31, 2025
7541848
feat: separate shell.nix and multiple systems
Mar 31, 2025
690a7ba
Update shell.nix
maningreen Mar 31, 2025
f5e393a
feat: added direnv support
Apr 1, 2025
a1b9dc2
feat(nix shell): added git and jq
Apr 1, 2025
cfab5be
finished basic devShell for the flake
maningreen Mar 31, 2025
27ec201
feat: separate shell.nix and multiple systems
Mar 31, 2025
22b9bef
Merge branch 'main' into main
electron271 May 10, 2025
d076905
Merge branch 'main' into main
electron271 May 11, 2025
8cfa34c
Merge branch 'main' into main
electron271 May 11, 2025
60055c7
finished basic devShell for the flake
maningreen Mar 31, 2025
1dc2d5b
chore: removed *.nix from gitignore
Mar 31, 2025
82fc216
chore: flake description
Mar 31, 2025
6c784be
refactor: flake inputs
Mar 31, 2025
8a1cb39
feat: separate shell.nix and multiple systems
Mar 31, 2025
c28dc6a
Update shell.nix
maningreen Mar 31, 2025
a7cc49a
feat: added direnv support
Apr 1, 2025
c36b8c8
feat(nix shell): added git and jq
Apr 1, 2025
8322b49
finished basic devShell for the flake
maningreen Mar 31, 2025
f6ebe17
feat: separate shell.nix and multiple systems
Mar 31, 2025
053de7f
Merge pull request #3 from midirhee12/main
maningreen May 13, 2025
ec41ba8
chore: remove .envrc
May 13, 2025
ddac04f
feat: added flake-parts & created envrc generator
May 13, 2025
c68d65a
Merge branch 'maningreen:main' into main
midirhee12 May 13, 2025
cad397b
Merge pull request #4 from midirhee12/main
maningreen May 13, 2025
4e968de
Merge branch 'main' into main
electron271 May 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ __pycache__/

# Replit
*.replit
*.nix

# C extensions
*.so
Expand Down Expand Up @@ -172,4 +171,7 @@ tux/extensions/*

# misc
slim.report.json
prisma_binaries/
prisma_binaries/

# direnv
.direnv/
62 changes: 62 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
description = "All Thing's Linux discord bot - Tux";

inputs = {
nixpkgs = {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
ref = "nixos-unstable";
};

flake-parts = {
type = "github";
owner = "hercules-ci";
repo = "flake-parts";
ref = "main";
};
};

outputs = inputs@{
self,
nixpkgs,
flake-parts,
...
}:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];

perSystem = { pkgs, self', system, ... }: {
devShells = {
default = self'.devShells.tux;
tux = pkgs.callPackage ./shell.nix { inherit pkgs self; };
};

apps.envrc = {
type = "app";
program = self'.packages.envrc;
};

# Creates .envrc if does not exist
packages.envrc = pkgs.writeShellScriptBin "envrc" ''
echo

if [ ! -e ".envrc" ]; then
echo "Creating .envrc"
printf "use flake .\n\n\n" | cat - .env.example > .envrc
echo

echo "The directory is now set up for direnv usage."
echo
else
echo "Please delete .envrc if you wish to recreate it."
echo
fi
'';
};
};
}
27 changes: 27 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{ pkgs ? import <nixpkgs> {}, self ? null }:

pkgs.mkShell {
buildInputs = if self == null then [] else [
self.packages.${pkgs.system}.envrc
];

packages = with pkgs; [
python313
poetry
git
jq
];

shellHook = ''
# See perSystem.packages.envrc
if command -v envrc >/dev/null 2>&1; then
envrc
fi

# Enters the user's preferred shell using a more robust method
$(getent passwd $(id -un) | cut -d: -f7 | tr -d '\n')

# Exits after child shell exits
exit
'';
}